How to duplicate a 2000 x 200 matrix n times
17 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Alex Mcaulley
2019 年 3 月 27 日
Try this:
repmat(A,60,1)
Is it that you want?
4 件のコメント
John D'Errico
2019 年 3 月 27 日
編集済み: John D'Errico
2019 年 3 月 27 日
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.
その他の回答 (1 件)
Jan
2019 年 3 月 27 日
編集済み: Jan
2019 年 3 月 27 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!