I have a 720 x 296 matrix, how can I specify for repeat this n times in some kind of loop like:
1 回表示 (過去 30 日間)
古いコメントを表示
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
.
..
0 件のコメント
採用された回答
Walter Roberson
2016 年 5 月 28 日
repmat(YourMatrix, n, 1)
perhaps? It is not clear what is to be repeated.
0 件のコメント
その他の回答 (1 件)
Stephen23
2016 年 5 月 29 日
編集済み: Stephen23
2016 年 5 月 29 日
Here are three very easy ways to repeat values in a loop.
Method One: define a vector before the loop:
>> vec = repmat(1:5,1,3);
>> for k = 1:numel(vec), disp(vec(k)), end
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
Method Two: use repmat to specify the loop variable:
>> for k = repmat(1:5,1,3), disp(k), end
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
Mehtod Three: use mod on the loop variable:
>> for k = 1:15, disp(1+mod(k-1,5)),end
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!