Filter returning NaN in a loop
Ältere Kommentare anzeigen
Hi, I am using filtfilt function (in MATLAB 2014b) inside a for loop. Basically what my loop does is that every time it loads a signal and applies the filtfilt function to it. Now problem is after the first file is done and the loop moves to the second file the result of the filtfilt function is all NaN and I don't know why.
NOTE: I checked the input file to the filtfilt, it does NOT have NaN in it. Also, I tried changing the filter, and used a simple filter command, still the same problem exists. I just updated my MATLAB from 2014a to 2014b, before the update everything worked just fine, so I don't know, but maybe it's a problem with the new version???
PLEASE people! Any answer is appreciated...
Thanks.
3 Kommentare
Geoff Hayes
am 29 Dez. 2014
Fatameh - please include some of the code so that we can see how your for loop is reading data from file and using the filtfilt function.
Jan
am 29 Dez. 2014
@Fatemeh: Currently there is only a very tiny chance, that the forum can guess the reason of the observed behavior. Either the input data or your code causes the NaNs, but we cannot see neither the code nor the data.
Fatemeh
am 29 Dez. 2014
Bearbeitet: Geoff Hayes
am 29 Dez. 2014
Antworten (1)
Star Strider
am 29 Dez. 2014
This may be your problem:
fdata_notch1 = filtfilt(b1,a1,data_unfilt);
fdata = filtfilt(b2,a2,fdata_notch);
In cascading your filters, you have to give the output of your first filter, ‘fdata_notch1’ here, to your second filter. I have no idea what may be in ‘fdata_notch’, but it’snot your signal!
Change the second line to:
fdata = filtfilt(b2,a2,fdata_notch1);
and see if that eliminates the NaN values
2 Kommentare
Fatemeh
am 29 Dez. 2014
Star Strider
am 29 Dez. 2014
OK.
I don’t have the DSP System Toolbox, so I can’t reproduce your ‘b1’ and ‘a1’. Attaching a .mat file with the coefficients would help.
Does ‘fdata_notch1’ have NaN values or only ‘fdata’?
Kategorien
Mehr zu Signal Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!