MATLAB: How to index a matrix with only one number in Matlab inside a loop

indexing matrix with only one numbermatrix indexing

Hello!
I'm new in the forum and I would like a little help… I'm facing the following problem: I have a loop variable k that goes from 1 to 12, and in each step k it has associated with it a matrix.
I would like to do something like this: x(1) = Matrix1, …,x(k) = Matrixk, but I can't…Matlab says "??? In an assignment A(I) = B, the number of elements in B and I must be the same."
Each k has a 19×73 matrix associated, so it will be useful to find a way to do this indexing…haha, meanwhile the program has 12 blocks just for do this job… Any help is appreciated. Thanks!

Best Answer

Use n-D array or cell array
%n-D array
x=zeros(12,19,73)
for k=1:12
x(k,:,:)=rand(19,73);
end
% cell array
x=cell(12,1);
for k=1:12
x{k}=rand(19,73);
end