Matlab - applying a low pass filter to a vector?

If I have a simple low pass filter like

filt = fir1(20, 0.2); 

and a matrix with a list of numbers (signal), for example. [0,1, -0,2, 0,3, -0,4] etc., How can I apply the filter that I created to this signal?

Sounds like a simple question, but I'm stuck for hours. Do I need to manually calculate it from the filter coefficients?

+4
source share
3 answers

Here you go:

 filter(filt, 1, mysignal); 

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

+5
source

The filter function is what you need.

I believe that help filter or doc filter bring you to you.

+1
source

Here you cannot give a value that is greater than 1 for the first argument of the fir1 function. It should be between 0 and 1. Let it be said that the cutoff frequency is Fc, and the sampling frequency is Fs, then if we take Wn as the first argument, which is the cutoff frequency as a normalized value. Here's how to calculate Wn.

  Wn = (2/Fs)*Fc 

Then you can apply the filter function as shown below:

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

Source: https://habr.com/ru/post/1308852/


All Articles