Compute standard deviations for each element across several matrices
9 次查看(过去 30 天)
显示 更早的评论
Hi everyone.
I have a cell array A.M_org{1, 1} ; A.M_org{1,2} etc. with 5 cells in total.
In each of the 5 cells I have another 3 cells such as A.M_org{1, 1} {1,i} where i is 1:3. Each cell contains a matrix of equal size namely 18x922.
I wanted then to calculate the mean for each element across the 3 matrices which works with:
A.M_avg = cellfun(@(x) {mean(cat(3, x{:}), 3)},A.M_org);
I wanted then calculate the standard deviation as well for each element across all the three Matrices such as for example for element 1 across the three matrices M1(1,1), M2(1,1), M2(1,1) using :
A.M_std = cellfun(@(x) {std(cat(3, x{:}), 3)},A.M_org);
this gave me an error saying :
Error using var (line 197)
W must be a vector of nonnegative weights, or a scalar 0 or 1.
Error in std (line 59)
y = sqrt(var(varargin{:}));
Error in @(x){std(cat(3,x{:}),3)}
does somebody know why the mean can be calculated this way for each element but the standard deviation can't?
Does anybody know how to compute the standard deviation of the elements across several matrices with equal size?
0 个评论
采纳的回答
Ameer Hamza
2020-10-22
2nd input to std() is a weight vector. Change it to this
std(cat(3, x{:}), [], 3)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!