Low Pass Filter returning NaN

13 views (last 30 days)
Ethan
Ethan on 14 Jun 2011
New user, here...
I'm trying to use a LPF on an array with data from a sensor. The sampling rate of the data is either 375/sec or 500/sec. The samples are between 1000/-1000.
I was successfully using the following script on one set of data:
%Low Pass Filter
f=500;
fNormLow = 2/(f/2);
[b1,a1] = butter(2,fNormLow,'low');
lowPass = filtfilt(b1,a1,rawData(:,1));
figure(3);
plot(lowPass(:,1),'-m')
hold on;
However, the same script doesn't work on a different set of data. lowPass(:,1) is entirely filled with NaN.
Can anyone lend some insight as to what I'm doing wrong? I'm thinking I need to try a FIR filter instead of an IIR, but I'm not sure why it works for the first set of data and not for the second. If the answer is a different filter, I'm hoping for a suggestion of which one to use. I'm looking for a very smooth sine wave to be made out of data with a periodic spike - pretty simple. Maybe someone could post an example?
Thanks in advance!
  2 Comments
Honglei Chen
Honglei Chen on 14 Jun 2011
You may want to check your raw data and see if it has things like NaN or Inf in there.
Ethan
Ethan on 14 Jun 2011
Thanks for the quick response!
There is one blank row in the txt file (when imported in to excel) -- however, there is more than one blank row in the data file that works. I used the "isnumber" function in excel to check if there was anything other than a number, and that blank row was the only hit.

Sign in to comment.

Answers (0)

Categories

Find more on Digital and Analog Filters in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!