开发者

Matlab - applying low-pass filter to a vector?

If I have a simple low-pass filter, e.g.

filt = fir1(20, 0.2);

and a matrix with a list of numbers (a signal), e.g. [0.1, -0.2,开发者_高级运维 0.3, -0.4] etc, how do I actually apply the filter I've created to this signal?

Seems like a simple question but I've been stuck for hours. Do I need to manually calculate it from the filter coefficients?


Here you go:

filter(filt, 1, mysignal);

will do the trick. Since this is an FIR filter, the A parameter (the second parameter) is set to 1.


The filter function is what you need.

I believe help filter or doc filter will get you on your way.


Here you cant give a value which is grater than 1 for the first argument of fir1 function. It should be between 0 and 1. Let's say cutoff frequency is Fc and sampling frequency is Fs, then if we take Wn as the first argument which is the cutoff frequency as a normalized value. This is how Wn should be calculated.

     Wn = (2/Fs)*Fc

Then you can apply filter function like below:

      filt = fir1(Wn , 0.2);
      filter(filt, 1, mysignal);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜