Thread Subject: Apply a simple low pass filter to a signal

Subject: Apply a simple low pass filter to a signal

From: Paul Walker

Date: 9 Nov, 2009 21:45:18

Message: 1 of 5

Hi, I have a simple response consisting in a data vector y and a time vector t which should be the frequency answer for an electric motor

If i graph it with the 'plot' function I can see some noises in the background (something with high frequency)

I designed a simple low pass filter with the transfer function 1/(1+tau*s) to filter every frequency over 30 Hz (the frequency of the response I need is something like 1-2 Hertz) but how to apply it to the signal?

I was not able to find any simple method or any method that worked to me, can someone please help?

Subject: Apply a simple low pass filter to a signal

From: jrenfree

Date: 9 Nov, 2009 21:50:15

Message: 2 of 5

On Nov 9, 1:45 pm, "Paul Walker" <gicat...@libero.it> wrote:
> Hi, I have a simple response consisting in a data vector y and a time vector t which should be the frequency answer for an electric motor
>
> If i graph it with the 'plot' function I can see some noises in the background (something with high frequency)
>
> I designed a simple low pass filter with the transfer function 1/(1+tau*s) to filter every frequency over 30 Hz (the frequency of the response I need is something like 1-2 Hertz) but how to apply it to the signal?
>
> I was not able to find any simple method or any method that worked to me, can someone please help?

How did you design the filter?

You should be able to just use the filter or filtfilt commands

Subject: Apply a simple low pass filter to a signal

From: Paul Walker

Date: 9 Nov, 2009 22:09:02

Message: 3 of 5

Thanks for the answer.

I designed the filter with numerator and denominator coefficients
1 and [0.005305 1]

This filter (I boded the graph with bode(1,[0.005305 1]) ) should approximately filter every frequency above 30Hz

The problem is that using

yf = filtfilt(1,[0.005305 1],y1);

where y1 is my signal vector and yf is the filtered output, gives me a vector of NaN (not a number)

Am i getting wrong with something?

Subject: Apply a simple low pass filter to a signal

From: Wayne King

Date: 9 Nov, 2009 22:47:01

Message: 4 of 5

"Paul Walker" <gicatena@libero.it> wrote in message <hda3tu$spn$1@fred.mathworks.com>...
> Thanks for the answer.
>
> I designed the filter with numerator and denominator coefficients
> 1 and [0.005305 1]
>
> This filter (I boded the graph with bode(1,[0.005305 1]) ) should approximately filter every frequency above 30Hz
>
> The problem is that using
>
> yf = filtfilt(1,[0.005305 1],y1);
>
> where y1 is my signal vector and yf is the filtered output, gives me a vector of NaN (not a number)
>
> Am i getting wrong with something?

Hi Paul, the first coefficient of your denominator must be a 1. It is the a0 term in the Z-transform of the recursive part. Also, I think the sign of the 0.005305 coefficient should be negative. Without getting into other ways to design your filter, I think you want to specify your all-pole filter as:

yf = filtfilt(1,[1 -0.005305],y1);

You can just look at the magnitude response with:

fvtool(1,[1 -0.005305])

If you change the sign of the a1 coefficient (the 2nd element with Matlab indexing) and call fvtool() you'll see you get a high pass, not a low pass filter.

Hope that helps,
Wayne

Subject: Apply a simple low pass filter to a signal

From: fburton@nyx.net (Francis Burton)

Date: 10 Nov, 2009 09:54:54

Message: 5 of 5

In article <hda2he$1qb$1@fred.mathworks.com>,
Paul Walker <gicatena@libero.it> wrote:
>Hi, I have a simple response consisting in a data vector y and a time
>vector t which should be the frequency answer for an electric motor
>
>If i graph it with the 'plot' function I can see some noises in the
>background (something with high frequency)
>
>I designed a simple low pass filter with the transfer function
>1/(1+tau*s) to filter every frequency over 30 Hz (the frequency of the
>response I need is something like 1-2 Hertz) but how to apply it to the
>signal?
>
>I was not able to find any simple method or any method that worked to
>me, can someone please help?

If you simply want to get rid of the higher frequencies, you
could filter in the frequency domain as described in Press et
al.'s NUMERICAL RECIPES book and implemented e.g. here:

http://www.mathworks.com/matlabcentral/fileexchange/25017-fft-filter-clean-your-signals-and-display-results
(http://tinyurl.com/y98pqwf)

Francis

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
low Paul Walker 9 Nov, 2009 16:49:04
pass Paul Walker 9 Nov, 2009 16:49:04
filter Paul Walker 9 Nov, 2009 16:49:04
electric Paul Walker 9 Nov, 2009 16:49:04
motor Paul Walker 9 Nov, 2009 16:49:04
response Paul Walker 9 Nov, 2009 16:49:04
apply Paul Walker 9 Nov, 2009 16:49:04
rssFeed for this Thread

Contact us at files@mathworks.com