How to save "for" loop outputs in cell array?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!