how can I create variable number of matrices (arrays) based on an arbitrary input.
Show older comments
I want to write a m-file that measures size of a matrix (I know how to do this) and then creates different number of variables (objects, variables, matrices or what ever you may call it) depending on size (which I don't know how to do). thank you all.
Answers (4)
Azzi Abdelmalek
on 8 Aug 2013
Suppose we have a matrix
a=[1 2 ; 3 4; 5 6];
%the size of a is
[n,m]=size(a)
%Now, what do you want to create? you have to tell us, if variables, which variables? if objects, which objects?
1 Comment
Saeed
on 12 Aug 2013
Andrei Bobrov
on 12 Aug 2013
Edited: Andrei Bobrov
on 12 Aug 2013
use cell arrays:
out = num2cell(A,2); % each cell - your new matrix
Categories
Find more on Matrix Indexing 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!