Calculating mean over multiple dimensions

33 vues (au cours des 30 derniers jours)
Akul Satish
Akul Satish le 17 Fév 2019
Modifié(e) : madhan ravi le 17 Fév 2019
I have a 3-dimensional variable that is of the class double, example: data has 50x2000x999. I would like to compute the mean for the 3rd dimension first, then the second dimension, and then the first dimension.
I know one way to do this is:
meandata = mean(data,3)
meandata = mean(meandata,2)
meandata = mean(meandata).
Is there a more efficient way to do this? In one line of code probably?
Thanks,
Akul

Réponses (1)

madhan ravi
madhan ravi le 17 Fév 2019
Modifié(e) : madhan ravi le 17 Fév 2019
mean(data,'all') % or
mean(data,[3 2 1])
  1 commentaire
madhan ravi
madhan ravi le 17 Fév 2019
Modifié(e) : madhan ravi le 17 Fév 2019
For prior versions:
mean(data(:))

Connectez-vous pour commenter.

Catégories

En savoir plus sur Test Model Components 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