Low Pass Filter returning NaN

조회 수: 13 (최근 30일)
Ethan
Ethan 2011년 6월 14일
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
Honglei Chen
Honglei Chen 2011년 6월 14일
You may want to check your raw data and see if it has things like NaN or Inf in there.
Ethan
Ethan 2011년 6월 14일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital and Analog Filters에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by