Low Pass Filter returning NaN
13 views (last 30 days)
Show older comments
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
on 14 Jun 2011
You may want to check your raw data and see if it has things like NaN or Inf in there.
Answers (0)
See Also
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!