Repmat:Replicate and tile an array

Repmat:Replicate and tile an array

Syntax

B = repmat(A,m,n)

B = repmat(A,[m n])

B = repmat(A,[m n p...])

Description

B = repmat(A,m,n) creates a large matrix B consisting of an m-by-n tiling of copies of A. The size of B is [size(A,1)*m, (size(A,2)*n]. The statement repmat(A,n) creates an n-by-n tiling.

B = repmat(A,[m n]) accomplishes the same result as repmat(A,m,n).

B = repmat(A,[m n p...]) produces a multidimensional array B composed of copies of A. The size of B is [size(A,1)*m, size(A,2)*n, size(A,3)*p, ...].

repmat(A,m,n) when A is a scalar, produces an m-by-n matrix filled with A‘s value and having A‘s class. For certain values, you can achieve the same results using other functions, as shown by the following examples: repmat(NaN,m,n) returns the same result as NaN(m,n). repmat(single(inf),m,n) is the same as inf(m,n,‘single‘). repmat(int8(0),m,n) is the same as zeros(m,n,‘int8‘). repmat(uint32(1),m,n) is the same as ones(m,n,‘uint32‘). repmat(eps,m,n) is the same as eps(ones(m,n)).

Examples

In this example, repmat replicates 12 copies of the second-order identity matrix, resulting in a "checkerboard" pattern.

B = repmat(eye(2),3,4) %size(eye(2),1) = 2; size(eye(2),2)=2;

B =  %(3*2;4*2;) eye(2)整体向右变为8;向下变为6

1     0     1     0     1     0     1     0

0     1     0     1     0     1     0     1

1     0     1     0     1     0     1     0

0     1     0     1     0     1     0     1

1     0     1     0     1     0     1     0

0     1     0     1     0     1     0     1

The statement N = repmat(NaN,[2 3]) creates a 2-by-3 matrix of NaNs.

时间: 2024-12-14 04:36:40

Repmat:Replicate and tile an array的相关文章

Matlab编程基础

平台:Win7 64 bit,Matlab R2014a(8.3) "Matlab"是"Matrix Laboratory" 的缩写,中文"矩阵实验室",是强大的数学工具.本文侧重于Matlab的编程语言侧面,讲述Matlab的基本语法,以及用Matlab语言进行程序设计.值得一提的是,Matlab从R2014a版本开始支持中文语言了! 1.基本概念 Matlab默认启动后界面: Matlab有关的文件后缀: File Extension Des

Matlab中所有自定义的函数

Functions By Category | Alphabetical List Language Fundamentals Entering Commands ans Most recent answer clc Clear Command Window diary Save Command Window text to file format Set display format for output home Send cursor home iskeyword Determine wh

UFLDL实验报告3:Self-taught

Self-taught 自我学习器实验报告 1.Self-taught 自我学习实验描述 自我学习是无监督特征学习算法,自我学习意味着算法能够从未标注数据中学习,从而使机器学习算法能够获得更大数量的数据,因而更有可能取得更好的性能.在本实验中,我们将按照自我学习的步骤,使用稀疏自编码器和softmax分类器去构造一个手写数字分类器. 实现流程 Step 1 :产生训输入和测试样本集 Step 2 :训练稀疏自编码器 Step 3 :提取特征 Step 4 :训练和测试softMax分类器 Ste

UFLDL实验报告2:Sparse Autoencoder

Sparse Autoencoder稀疏自编码器实验报告 1.Sparse Autoencoder稀疏自编码器实验描述 自编码神经网络是一种无监督学习算法,它使用了反向传播算法,并让目标值等于输入值,比如 .自编码神经网络尝试学习一个 的函数.换句话说,它尝试逼近一个恒等函数,从而使得输出 接近于输入 .当我们为自编码神经网络加入某些限制,比如给隐藏神经元加入稀疏性限制,那么自编码神经网络即使在隐藏神经元数量较多的情况下仍然可以发现输入数据中一些有趣的结构.稀疏性可以被简单地解释如下.如果当神经

K近邻分类算法实现 in Python

K近邻(KNN):分类算法 * KNN是non-parametric分类器(不做分布形式的假设,直接从数据估计概率密度),是memory-based learning. * KNN不适用于高维数据(curse of dimension) * Machine Learning的Python库很多,比如mlpy(更多packages),这里实现只是为了掌握方法 * MATLAB 中的调用,见<MATLAB分类器大全(svm,knn,随机森林等)> * KNN算法复杂度高(可用KD树优化,C中可以用

K-近邻算法python实现

内容主要来源于机器学习实战这本书,加上自己的理解. 1.KNN算法的简单描述 K最近邻(k-Nearest Neighbor,KNN)分类算法可以说是最简单的机器学习算法了.它采用测量不同特征值之间的距离方法进行分类.它的思想很简单:如果一个样本在特征空间中的k个最相似(即特征空间中最邻近)的样本中的大多数属于某一个类别,则该样本也属于这个类别.下图是大家引用的一个最经典示例图. 比如上面这个图,我们有两类数据,分别是蓝色方块和红色三角形,他们分布在一个上图的二维中间中.那么假如我们有一个绿色圆

100道numpy练习

100道numpy练习 @author:wepon @blog:http://blog.csdn.net/u012162613/article/details/42784403 今天在deeplearning.net上看theano tutorial,发现一个numpy-100-exercise,介绍numpy一些基本用法的,不过不是很具体,我利用闲暇时间照着敲了一些,权且当作翻译吧,增加函数的原型和详细介绍.持续更新. 一.初学者10道 1.在python环境中导入numpy包,并命名为np

100 numpy exercises

100 numpy exercises A joint effort of the numpy community The goal is both to offer a quick reference for new and old users and to provide also a set of exercices for those who teach. If you remember having asked or answered a (short) problem, you ca

机器学习中(Feature Scaling)特征缩放处理的matlab实现方式

在进行特征缩放的时候,其一般做法是(X-mu)/sigma mu:代表均值 sigma:代表标准差 在matlab中,函数mean可以求特征的均值,函数std可以求特征的标准差. 假设训练集为m,特征数量为n,特征矩阵为X,则X的size为 m*n. 则 mu = mean(X)返回值为一个1*n的向量,向量中每个值对应于每个特征的均值. 则 sigma = std(X) 返回值为一个1*n的向量,向量中每个值对应于每个特征的标准差. 为了进行特征缩放,我们需要使用matlab中另外一个函数re