Filter löschen
Filter löschen

Mean over a multidimensionnal Cell

1 Ansicht (letzte 30 Tage)
Florian
Florian am 27 Mär. 2014
Kommentiert: Florian am 27 Mär. 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

Akzeptierte Antwort

A Jenkins
A Jenkins am 27 Mär. 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 Kommentar
Florian
Florian am 27 Mär. 2014
Thank you, I didn't know the vertcat function, newbie ;) Florian

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by