How to calculate moving standard deviation in a matrix?
显示 更早的评论
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?
回答(1 个)
Manolis Michailidis
2015-10-13
0 个投票
7 个评论
Andrea Finocchiaro
2015-10-13
Manolis Michailidis
2015-10-13
编辑:Manolis Michailidis
2015-10-13
what errors do you get discribe them please and write your code
Manolis Michailidis
2015-10-13
编辑:Manolis Michailidis
2015-10-13
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
2015-10-13
Manolis Michailidis
2015-10-13
编辑:Manolis Michailidis
2015-10-13
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
2015-10-13
Manolis Michailidis
2015-10-13
编辑:Manolis Michailidis
2015-10-13
for kk=1:size(X,2) % kk is your column index
s(1:180,kk)=movingstd(X(1:180,kk),180,'f');
end
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!