Effacer les filtres
Effacer les filtres

Averaging multiple matrices with the cell array

7 vues (au cours des 30 derniers jours)
Abdulhakim Alezzi
Abdulhakim Alezzi le 31 Jan 2021
Commenté : Star Strider le 1 Fév 2021
Hi Guys,
I have a cell array (C) with (1*22), inside this cell i have 22 matrices with (30*30*20).
I want to have the average of all these matrices, so the final output must be in the same dimention (30*30*20).
I have tried this code, but the output was different
for f=1:1:length(C)
for i=1:30
for j=1:20
data=cell2mat(C(f));
end
end
end

Réponse acceptée

Star Strider
Star Strider le 31 Jan 2021
Try this:
Cmean = mean(cat(4,C{:}),4);
That concatenates the cells across dimension 4 and then takes the mean across dimension 4.
  2 commentaires
Abdulhakim Alezzi
Abdulhakim Alezzi le 1 Fév 2021
Thank you very much
Star Strider
Star Strider le 1 Fév 2021
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by