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!