How to access data in a cell array?

4 vues (au cours des 30 derniers jours)
Susan
Susan le 8 Fév 2021
Commenté : Susan le 10 Fév 2021
Hi,
I have an 40*8 cell array, called Q. Each cell contains an 64×64×128 double matrix.
I would like to have a foor loop on the 3rd dimension of each matrix in these cells. How can I do that? Thanks!
  2 commentaires
Susan
Susan le 9 Fév 2021
Hi Samuel,
Thanks for your reply and sorry that I didn't clarify what exactly I want the for loop to do for me. I tried to explain it below. Any feedback would be greatly appreciated.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 9 Fév 2021
mask = ~cellfun(@isempty, Q);
results = cell(size(Q));
results(mask) = cellfun(@(C) DO_SOMETHING_3D(C), Q(mask), 'uniform', 0);
For example,
mask = ~cellfun(@isempty, Q);
results = cell(size(Q));
results(mask) = cellfun(@(C) sum(C, 3), Q(mask), 'uniform', 0);
  5 commentaires
Susan
Susan le 10 Fév 2021
Thanks again for your detailed reply.
Yes, my calculation needs to know which is the current cell index in order to know what it is calculating and I think putting everything together would need to be 64 x 64 x 128 x 40 x 8 since the output should be an 40 x 8 cell array that each array contains a 64 x 64 x128 matrix.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by