Stacking matrices in a larger matrix in a loop
조회 수: 1 (최근 30일)
이전 댓글 표시
I now need to stack matrices formed in a loop on top of each other to create a larger matrix.
For example, I have a loop that goes around 4 times, each time it creates a 9 x 4 matrix. I need to store each iterative matrix in a larger matrix by stacking them one on top of each other, to get a matrix of dimensions 36 x 4.
Any ideas how I can do this?
Cheers
Danny
댓글 수: 0
답변 (1개)
Azzi Abdelmalek
2013년 11월 8일
out=zeros(36,4) % Pre-allocate
for k=1:4
A=rand(9,4);
out((k-1)*9+1:k*9,:)=A
end
참고 항목
카테고리
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!