how to average a vector of arrays in Matlab
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
im new to matlab and I'd like to average a vector of arrays in matlab?
i have a vector of size (1,72) each column has an array of size(22,22)
i wanna avgerge the vector to get a desired output of (22,22)
i have tried this piece of code
for i= 1:72
wholeMean1{1} = mean(indexes_every.PLV.data {1,i}, 1); %% the output (1,22)
wholeMean2{1} = mean(indexes_every.PLV.data {1,i}, 2); %% the output (22,1)
wholeMean3{1} = mean(indexes_every.PLV.data {1,i}, 3); %% the output (22,22) ##
end
i just want to verfiy my result.
am i doing it correctly ?
thx in advanced
0 件のコメント
回答 (2 件)
Image Analyst
2022 年 6 月 27 日
One simple intuitive way is to just add up all the arrays and divide by the number of the arrays
numArrays = numel(indexes_every.PLV.data)
sumMatrix = zeros(22, 22);
for k = 1 : numArrays
sumMatrix = sumMatrix + indexes_every.PLV.data{k};
end
meanMatrix = sumMatrix / numArrays
0 件のコメント
Steven Lord
2022 年 6 月 27 日
Concatenate them in the third dimension then call mean with the dimension input.
M = magic(4)
E = eye(4)
N = ones(4)
C = {M, E, N}
A = cat(3, C{:})
mean(A, 3)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!