How to calculate moving standard deviation in a matrix?
Mostrar comentarios más antiguos
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?
Respuestas (1)
Manolis Michailidis
el 13 de Oct. de 2015
0 votos
7 comentarios
Andrea Finocchiaro
el 13 de Oct. de 2015
Manolis Michailidis
el 13 de Oct. de 2015
Editada: Manolis Michailidis
el 13 de Oct. de 2015
what errors do you get discribe them please and write your code
Manolis Michailidis
el 13 de Oct. de 2015
Editada: Manolis Michailidis
el 13 de Oct. de 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
el 13 de Oct. de 2015
Manolis Michailidis
el 13 de Oct. de 2015
Editada: Manolis Michailidis
el 13 de Oct. de 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
el 13 de Oct. de 2015
Manolis Michailidis
el 13 de Oct. de 2015
Editada: Manolis Michailidis
el 13 de Oct. de 2015
for kk=1:size(X,2) % kk is your column index
s(1:180,kk)=movingstd(X(1:180,kk),180,'f');
end
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!