フィルターのクリア

Function for Calculating Moving sum

1 回表示 (過去 30 日間)
John
John 2012 年 7 月 16 日
コメント済み: Image Analyst 2017 年 10 月 12 日
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 日
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 件のコメント
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 日
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);

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by