作业帮 > 综合 > 作业

matlab中 repmat([1:N]',[1,2]),

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/01 11:12:28
matlab中 repmat([1:N]',[1,2]),
epmat是将矩阵按要求扩增.repmat([1:N]',[1,2])):就是将[1:N]'看成一个整体,就相当于一个元素,将这个大的“元素”扩增为1x2的矩阵,如果p是整数,则就是将1x2矩阵p倍输出,即三维扩增.以下是Matlab的help结果:
REPMAT Replicate and tile an array.
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 ...]) tiles the array A to produce 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 is commonly used to produce an M-by-N
matrix filled with A's value and having A's CLASS.For certain values,
you may achieve the same results using other functions.Namely,
REPMAT(NAN,M,N) is the same 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))
再问: P是一个NX1的矩阵,如果将之前已经按1x2扩大为NX2的矩阵看作一个整体,这个statement最后的效果就是将NX*2这个整体扩增为Nx1的矩阵,最后矩阵的大小为N*NX2,对吗,我怕我理解有误...谢谢~