フィルターのクリア

Mean over a multidimensionnal Cell

1 回表示 (過去 30 日間)
Florian
Florian 2014 年 3 月 27 日
コメント済み: Florian 2014 年 3 月 27 日
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

採用された回答

A Jenkins
A Jenkins 2014 年 3 月 27 日
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 件のコメント
Florian
Florian 2014 年 3 月 27 日
Thank you, I didn't know the vertcat function, newbie ;) Florian

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by