How to calculate moving standard deviation in a matrix?
Afficher commentaires plus anciens
Hi Guys, I have got a matrix :378x9. I need to calculate the moving standard deviation with a window size of 180(starting from row one). Can somebody help me please?
Réponses (1)
Manolis Michailidis
le 13 Oct 2015
0 votes
7 commentaires
Andrea Finocchiaro
le 13 Oct 2015
Manolis Michailidis
le 13 Oct 2015
Modifié(e) : Manolis Michailidis
le 13 Oct 2015
what errors do you get discribe them please and write your code
Manolis Michailidis
le 13 Oct 2015
Modifié(e) : Manolis Michailidis
le 13 Oct 2015
Here i made a try and it works fine
X= [randi(10,1000,1) randi(100,1000,1)]; %create random matrix wit 2 columns
for kk=1:size(X,2)
s(:,kk)=movingstd(X(:,kk),180,'f');
end
also consider in mind that in this example i compute the moving std per column , also you can make it work for each row. Just replace size(X,2) with size(X,1) and s(:,kk) , X(:,kk) with s(kk,:), X(kk,:) .
Andrea Finocchiaro
le 13 Oct 2015
Manolis Michailidis
le 13 Oct 2015
Modifié(e) : Manolis Michailidis
le 13 Oct 2015
You don't have to type all this in command window, look at the function syntax , first variable is you matrix (lets say X) , next is moving window length (180) and finally optional parameter is 'f' forward. You have already the function why don't you call it?
Andrea Finocchiaro
le 13 Oct 2015
Manolis Michailidis
le 13 Oct 2015
Modifié(e) : Manolis Michailidis
le 13 Oct 2015
for kk=1:size(X,2) % kk is your column index
s(1:180,kk)=movingstd(X(1:180,kk),180,'f');
end
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!