MATLAB: I have a 19x256x256 STM image in an array form that I need to transform

cell arraysfor loopMATLABmatrix manipulation

I want to take my 19x256x256 array and write into 256 separate matrices, which I think can be done using reshape. I also want to write each matrix automatically into a new "layer" i.e. plane1=A(:,:,1), plane2=A(:,:,2),….,plane256=A(:,:,256). Is there a way of doing this with some sort of looping so that each new variable is stored automatically?

Best Answer

Using a cell array, with one element for each matrix, would be a much more sane way to do something like what you are asking for
N = 256;
A_cell = cell(N,1);
for nc = 1:N
A_cell{nc} = A(:,:,nc);
end
Then you can reference A_cell{137} in the same way you want to reference the variable plane137. But it is not clearly better to me that simply referencing A(:,:,137).