How to save "for" loop outputs in cell array?
이전 댓글 표시
I generated a code that gives all the 2x2 submatrices from a 10x7 matrix while keeping the order. I want to save each output (submatrix) as a matrix in a cell array to view it later. Here's my code:
Any help is appreciated!
clear
clc
matrix=rand(10,7)
[r, c]= size(matrix);
for s=1:r-1
for n=s+1:r-s
for j=1:c
for i=j+1:c
submatrix=matrix([s n],[j i])
end
end
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!