How to duplicate a 2000 x 200 matrix n times
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Saugata Bose
am 27 Mär. 2019
Kommentiert: Saugata Bose
am 27 Mär. 2019
Dear
I have a matrix of size 2000 x 200 double. I am looking forward to duplicate this matrix 60 times as it is.
So if the matrix A is like
A=[1 2 3;4 5 6] and if I repeat it 2 times it must be like A=[1 2 3; 4 5 6; 1 2 3; 4 5 6; 1 2 3 ; 4 5 6]
I have tried to do this like
repmat(A,60,200);.
But it is producing the following error:
Error using repmat
Requested 6705122x31684 (1582.8GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.
Would you please show me the suitable way to duplicate the matrix?
Thanks,
0 Kommentare
Akzeptierte Antwort
Alex Mcaulley
am 27 Mär. 2019
Try this:
repmat(A,60,1)
Is it that you want?
4 Kommentare
John D'Errico
am 27 Mär. 2019
Bearbeitet: John D'Errico
am 27 Mär. 2019
To respond, suppose you created a simple 2x2 array, then did this:
A = ones(2,2);
size(repmat(A,3,4))
ans =
6 8
In this example, repmat replicates the first dimension here by 3. And the second dimension gets replicated by 4.
By extension, all you wanted to do was to replicate the matrix 60 times, just adding extra rows to the matrix. You wanted to leave the columns unchanged.
If you leave out the 1 completely, just use repmat(A,3), this happens:
size(repmat(A,3))
ans =
6 6
So both the rows and columns of A get replicated there.
Ergo the 1.
Weitere Antworten (1)
Jan
am 27 Mär. 2019
Bearbeitet: Jan
am 27 Mär. 2019
You mean:
repmat(A, 61, 1)
In your example, you have "repeated" the input [2 x 3] matrix to the output [3 x 3] and call thims "2 times", so I assume you want 61 copies of the origibnal matrix.
Your code repmat(A,60,200) would repeat A "59" times horizontally and "199" times vertically.
By the way, you want to create a [2000 * 61 x 200] matrix. If this has the type double, it requires 192 MB.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!