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.

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

  1. Matlab编程基础

    平台:Win7 64 bit,Matlab R2014a(8.3) “Matlab”是“Matrix Laboratory” 的缩写,中文“矩阵实验室”,是强大的数学工具.本文侧重于Matlab的编程 ...

  2. [Python Cookbook] Numpy: Multiple Ways to Create an Array

    Convert from list Apply np.array() method to convert a list to a numpy array: import numpy as np myl ...

  3. UFLDL实验报告3:Self-taught

    Self-taught 自我学习器实验报告 1.Self-taught 自我学习实验描述 自我学习是无监督特征学习算法,自我学习意味着算法能够从未标注数据中学习,从而使机器学习算法能够获得更大数量的数 ...

  4. K近邻分类算法实现 in Python

    K近邻(KNN):分类算法 * KNN是non-parametric分类器(不做分布形式的假设,直接从数据估计概率密度),是memory-based learning. * KNN不适用于高维数据(c ...

  5. UFLDL实验报告2:Sparse Autoencoder

    Sparse Autoencoder稀疏自编码器实验报告 1.Sparse Autoencoder稀疏自编码器实验描述 自编码神经网络是一种无监督学习算法,它使用了反向传播算法,并让目标值等于输入值, ...

  6. K-近邻算法python实现

    内容主要来源于机器学习实战这本书.加上自己的理解. 1.KNN算法的简单描写叙述 K近期邻(k-Nearest Neighbor.KNN)分类算法能够说是最简单的机器学习算法了. 它採用測量不同特征值 ...

  7. R语言︱分布函数与概率密度+随机数产生

    1.常见概率分布 ##正态分布 pnorm(1.96) #P(x<=1.96)时的分布概率 pnorm(1.96,0,1) #上同 pnorm(1.96,lower.tail = F) #P(x ...

  8. 机器学习之--KNN算法简单实现

    # # kNN 分类算法 a = np.array([[1,1],[1.2,1.5],[0.3,0.4],[0.2,0.5]]) #构造样本数据 labels = ['A','A','B','B'] ...

  9. tensorflow faster rcnn 代码分析一 demo.py

    os.environ["CUDA_VISIBLE_DEVICES"]=2 # 设置使用的GPU tfconfig=tf.ConfigProto(allow_soft_placeme ...

随机推荐

  1. keystone DB in devstack

    ~$ mysql -u -p root mysql> use keystone; mysql> show tables;+------------------------+| Tables ...

  2. 机器学习(二)—支持向量机SVM

    1.SVM的原理是什么? SVM是一种二类分类模型.它的基本模型是在特征空间中寻找间隔最大化的分离超平面的线性分类器.(间隔最大是它有别于感知机) 试图寻找一个超平面来对样本分割,把样本中的正例和反例 ...

  3. hdu 5239 Doom(线段树)

    Doom Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Sub ...

  4. Spring_学习_00_资源帖

    一.官方文档 1.Spring Framework Documentation 二.参考书籍 1.< Spring实战 (第四版)> 三.参考资料

  5. LeetCode OJ:Combinations (排列组合)

    Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...

  6. LeetCode OJ:House Robber(住宅窃贼)

    You are a professional robber planning to rob houses along a street. Each house has a certain amount ...

  7. idea下建立bootstrap项目

    环境准备: 1.创建一个static web名为bootstrapDemo 2.在bootstrapDemo文件夹下安装bower npm install bower 会自动产生node-module ...

  8. linux install JDK

    安装JDK 下载jdk-6u23-linux-i586.bin,samba,FTP cd /usr/local/src/ wget http://www.aminglinux.com/bbs/data ...

  9. hdoj-3791-二叉搜索树(二叉搜索树模板题)

    #include <cstring> #include <cstdio> #include <iostream> using namespace std; type ...

  10. 20165210 预习作业3 Linux安装及学习

    Linux安装及学习 一.Linux安装 通过参考教程:基于VirtualBox虚拟机安装Ubuntu图文教程成功的安装上了Linux但在过程中还是有一些小问题的. 首先按着步骤走,一开始没什么毛病, ...