mean over over multiple dimensions and multiple arrays

3 ビュー (過去 30 日間)
Belinda Finlay
Belinda Finlay 2020 年 7 月 30 日
コメント済み: Belinda Finlay 2020 年 7 月 30 日
I have a 1*8 cell array, each martrix in the cell array is 814*1294*40. I want to take the average of each element over the 8 arrays.
Each of the 8 matrix are temp values in the x,y and the 3 dimension is depth. So i am seeking to to average each x,y element over the 8 arrays at each depth, resulting in one 814*1294*40 array.
Thanks
Belinda

採用された回答

KSSV
KSSV 2020 年 7 月 30 日
% make dummy data
N = 8 ;
for i = 1:N
C{i} = rand(2,2,3) ;
end
% get the mean
N = length(C) ;
[m,n,p] = size(C{1}) ;
themean = zeros(m,n,p) ;
for i = 1:N
themean = themean+C{i} ;
end
themean = themean/N ;
Can be obtained without loop, using Cell2mat, reshape etc.
  1 件のコメント
Belinda Finlay
Belinda Finlay 2020 年 7 月 30 日
Thank you, works perfectly.

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

その他の回答 (0 件)

カテゴリ

Find more on Cell Arrays in Help Center and File Exchange

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by