how to get the first position in the array and get size array contains matrices
Show older comments
Dear all,
I have a problem and I hope somebody can help.
I want to get the first index in the array, the array contains matrices and I want to get the first matrix, then I will do a loop start from the second matrix to the last matrix.
and I want to get size, I use "size" function but it returns " 4 2", how can I use the first number
note: assume array come form parameter of the function and it's hidden I don't know what array contain and the size of the array is unknown
example of the array :
m1=[ 0 1; 0 0];
m2=[ 0 1; 0 1];
m3=[ 1 1; 0 0];
m4=[ 1 1; 0 1];
array=[m1 m2 m3 m4];
index1=array(1);%not working
I hope I am clear enough.
Thanks in advance,
Ghaida
Answers (1)
Use a cell array:
>> C = {m1,m2,m3,m4};
>> C{1}
ans =
0 1
0 0
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!