if i have matrix of 20X2048 and i want to make it 20000X2048 how to do it

3 Ansichten (letzte 30 Tage)
matrix size = 20 x 2048
new matrix size =20000 x 2048

Antworten (1)

John D'Errico
John D'Errico am 3 Nov. 2022
help repmat
REPMAT Replicate and tile an array. B = REPMAT(A,M,N) or B = REPMAT(A,[M,N]) creates a large matrix B consisting of an M-by-N tiling of copies of A. If A is a matrix, the size of B is [size(A,1)*M, size(A,2)*N]. B = REPMAT(A,N) creates an N-by-N tiling. B = REPMAT(A,P1,P2,...,Pn) or B = REPMAT(A,[P1,P2,...,Pn]) tiles the array A to produce an n-dimensional array B composed of copies of A. The size of B is [size(A,1)*P1, size(A,2)*P2, ..., size(A,n)*Pn]. If A is m-dimensional with m > n, an m-dimensional array B is returned. In this case, the size of B is [size(A,1)*P1, size(A,2)*P2, ..., size(A,n)*Pn, size(A, n+1), ..., size(A, m)]. 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)) Example: repmat(magic(2), 2, 3) repmat(uint8(5), 2, 3) Class support for input A: float: double, single integer: uint8, int8, uint16, int16, uint32, int32, uint64, int64 char, logical See also BSXFUN, MESHGRID, ONES, ZEROS, NAN, INF. Documentation for repmat doc repmat Other uses of repmat codistributed/repmat lti/repmat symfun/repmat gpuArray/repmat matlab/repmat tall/repmat InputOutputModel/repmat
  3 Kommentare
Walter Roberson
Walter Roberson am 4 Nov. 2022
NewMatrix = repmat(Matrix, 20000/size(Matrix,1), 1)
or
NewMatrix = repelem(Matrix, 20000/size(Matrix,1), 1)
The difference is whether you want to repeat the first element 1000 times, then the second element 1000 times, and so on (if so, repelem), or if you want to repeat have all 20 values in order, followed by the same 20 in order, then again and again and again 1000 times
Stephen23
Stephen23 am 4 Nov. 2022
"but this will also change the column dmension."
Only if you tell it to. If you specify the column replication as 1, then the number of columns won't change.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by