How to Design a Moving average filter?

Hi everyone im kinda new with filter design in Matlab and in need of some help..
So basically i need to reduce the noise in an record and playback system based on DSP TMS320c6713.
Right now im stuck in writing the code for Moving average filter (exponential or simple). so can somebody help me out or give me some examples please.. I've been reading a lot and still dont seem to understand much!! Thanks in advance..

1 件のコメント

pankaj jood
pankaj jood 2017 年 6 月 22 日
M = movmean(A,k) M = movmean(A,[kb kf]) M = movmean(___,dim) M = movmean(___,nanflag) M = movmean(___,Name,Value)

サインインしてコメントする。

 採用された回答

Wayne King
Wayne King 2014 年 2 月 1 日
編集済み: Wayne King 2014 年 2 月 1 日

7 投票

To implement a simple causal moving average filter in MATLAB, use filter()
Ten-point moving average filter
B = 1/10*ones(10,1);
out = filter(B,1,input);
Adjust as needed for a different number of time steps.

7 件のコメント

mohsen
mohsen 2014 年 2 月 2 日
Thank you Wayne.. could u tell me how this works please? i have no idea!!
Wayne King
Wayne King 2014 年 2 月 2 日
It is mathematically equivalent to
y(n) = 1/N(x(n)+x(n-1)+x(n-2)+....x(n-N))
so for each n, y(n) is the average of the preceding n points.
Obviously at the beginning of the output, y(n), it is an average of fewer points because you don't have N points in the past.
nani kalyan
nani kalyan 2015 年 4 月 20 日
i am having 24000 values, so how can i filter hese all value please will you say me the code to enter in MATLAB SCRIPT.
Image Analyst
Image Analyst 2015 年 4 月 20 日
You can use Wayne's code. I'm going to adapt it slightly to give an odd number for the filter width so there's not a time shift between the output signal and the input signal.
windowWidth = 11; % Whatever you want.
kernel = ones(windowWidth,1) / windowWidth;
out = filter(kernel, 1, yourInputSignal);
3011
3011 2015 年 10 月 24 日
What code shall I use if I want to develop a simple non-causal moving average filter? what alterations should will there be?
Christopher Bitikofer
Christopher Bitikofer 2018 年 8 月 23 日
I think using filtfilt would work... I'm trying to figure something similar out
Osman Atay Öztürk
Osman Atay Öztürk 2021 年 8 月 24 日
windowWidth = 11; % Whatever you want.
kernel = ones(windowWidth,1) / windowWidth;
out = filter(kernel, 1, yourInputSignal);
How can I know this window width?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by