Compute standard deviations for each element across several matrices
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kim Arnold
am 22 Okt. 2020
Kommentiert: Ameer Hamza
am 22 Okt. 2020
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 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 22 Okt. 2020
2nd input to std() is a weight vector. Change it to this
std(cat(3, x{:}), [], 3)
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!