Save unlimited matrix from cell arrays

Hello, I get a cell array which contains 103 cells of different dimensions. Each cell represents a matrix and it can be displayed as an image. How can I extract each matrix in a for loop?
According to an old message published on matlab answers (<http://www.mathworks.com/matlabcentral/answers/36876-how-to-extract-cell-arrays-contained-in-a-cell)>, I know how to do that one by one but not for the whole cell :
image1 = cellArray{1}; % extract matrix 1 (on 103) from the cell array #1
image2 = cellArray{2}; % and so on.
Thanks for your help

4 Comments

I'm not sure I understand your structure.
Do you have one cell array with a matrix in each element, or do you have an array of 103 cells which each contains another cell array with a certain number of matrices?
I.e. is it
my_array = cell(103,1);
my_array{1} = randn(4,4); % some matrix
my_array{2} = randn(5,5); % etc.
or
my_array = cell(103,1);
my_array{1} = cell(3,1);
my_array{1}{1} = randn(4,4); % some matrix
my_array{1}{2} = randn(5,5); % etc.
my_array{2} = cell(2,1);
my_array{2}{1} = randn(4,4); % some matrix
my_array{2}{2} = randn(5,5); % etc.
Thanks for your answer. Actually, I think the first option is right (a cell array with 103 cells where each cell contains a matrix). This is my cell structure :
my_array =
Columns 1 through 6
[21x21 double] [21x21 double] [21x16 double] ... % and so on until 103
Why not just a simple for loop?
i.e.
n_cols = size(my_array,2); % 103 in your case
for i = 1:n_cols
image = my_array{i};
% do whatever processing you need
end
Ok. Thanks.

Sign in to comment.

Answers (0)

Categories

Asked:

on 15 Oct 2015

Commented:

on 15 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!