How to create matrix with Standard deviation from every 5 columns of another matrix?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kiryl Zhaliazka
le 30 Sep 2021
Réponse apportée : the cyclist
le 30 Sep 2021
I have matrix 100x20, how to create a new matrix with SD of evey 5 columns from the first one, to have 100x4 new matrix.
0 commentaires
Réponse acceptée
the cyclist
le 30 Sep 2021
Here is one way:
% Pretend data [Use your actual data instead]
M = randn(100,20);
% Reshape into the slices needed for standard deviation
M3 = reshape(M,100,5,4);
% Take standard deviation along dimension 2
S3 = std(M3,0,2); % FYI, the 0 here means "use sample, not population std dev". (See documentation.)
% Reshape back to 2-d
S = reshape(S3,100,4);
0 commentaires
Plus de réponses (1)
Walter Roberson
le 30 Sep 2021
M = rand(100,20);
Mstd5 = reshape(std(reshape(M, size(M,1), 5, []), [], 2), size(M,1), []);
size(Mstd5)
0 commentaires
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!