Is there any function to calculate moving sum of a vector? I use "smooth" for calculating the moving average of a vector

댓글 수: 1

F.
F. 2012년 7월 16일
I'm sorry but I don't understand "moving sum of a vector" ... Could you explain it and give a little exemple ? thanks

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2012년 7월 16일
편집: Image Analyst 2012년 7월 16일

1 개 추천

For a "moving" sum - the sum in a window - you can use conv(), or conv2() in two dimensions:
windowWidth = 15; % or whatever.
movingSum = conv(oneDsignal, ones(1, windowWidth));
for the moving average:
windowWidth = 15; % or whatever.
movingAverage = conv(oneDsignal, ones(1, windowWidth) / windowWidth);

댓글 수: 4

Kaustella Kialain
Kaustella Kialain 2015년 4월 8일
what is oneDsignal?
Stephen23
Stephen23 2015년 4월 8일
In this case oneDsignal is the input data to be smoothed, and the ones(..) term defines the smoothing window.
Tina Fuhrmann
Tina Fuhrmann 2017년 10월 11일
Why does it work with conv?
Image Analyst
Image Analyst 2017년 10월 12일
Why wouldn't it? If you replace each element with the average of elements around it, which is what conv() can do, then that's the moving average.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jonathan Sullivan
Jonathan Sullivan 2012년 7월 16일

2 개 추천

help filter
doc filter
Example: Take a 10 element moving average.
x = rand(1e3,1);
n = 10;
x_moving_average = filter(ones(1,n)/n,1,x);

카테고리

태그

질문:

2012년 7월 16일

댓글:

2017년 10월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by