Compute standard deviations for each element across several matrices
조회 수: 21 (최근 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)
댓글 수: 2
추가 답변 (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!