matrix store issue for loop iteration
이전 댓글 표시
for i=1:3
------------
r=[s m]
The S and M matrix are 1 by 3 matrix. The result "r" matrix is 3 by 2.
The code above is generates combines 2 matrices that is S and M matrix. It generate r matrix output at i=1 upto i =3, but the only last value outputs are stored in "r" matrix that is for i=3.
답변 (1개)
KSSV
2020년 10월 9일
r = cell(1,3) ;
for i = 1:3
r{i} = [s m]
end
If You feel r will have same size m*p in every iteration, you can initilaize this as a 3D matrix.
r = zeros(m,p,3) ;
for i = 1:3
r(:,:,i) = [s m] ;
end
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!