Effacer les filtres
Effacer les filtres

Mean over a multidimensionnal Cell

1 vue (au cours des 30 derniers jours)
Florian
Florian le 27 Mar 2014
Commenté : Florian le 27 Mar 2014
Hi all,
I got a cell whose form is as follow :
data{number_of_file,1}(number_of_line,number_of_columns)
I'd like to average over, for instance, the first line of the first column over all files, then the second line of the first column over all files, etc.
What would you suggest ? I've tried :
for j=1:length(data{1,1}) % loop over all lines
meanP=nanmean(data{:,1}(j,1)); % loop over all files for the j line
end
But I end up with this message : Bad cell reference operation.
Thanks
Florian

Réponse acceptée

A Jenkins
A Jenkins le 27 Mar 2014
You want the average of per-line of all the files? If all of the data are the same number of rows, then you can concatenate them together and average the rows in one line:
data{1,1}=rand(3,3);
data{2,1}=rand(3,3);
meanP=nanmean(horzcat(data{:,1}),2); %by row
Or by column:
meanP=nanmean(vertcat(data{:,1}),1); %by column
  1 commentaire
Florian
Florian le 27 Mar 2014
Thank you, I didn't know the vertcat function, newbie ;) Florian

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices 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