Filter returning NaN in a loop
Afficher commentaires plus anciens
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 commentaires
Geoff Hayes
le 29 Déc 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
le 29 Déc 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
le 29 Déc 2014
Modifié(e) : Geoff Hayes
le 29 Déc 2014
Réponses (1)
Star Strider
le 29 Déc 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 commentaires
Fatemeh
le 29 Déc 2014
Star Strider
le 29 Déc 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’?
Catégories
En savoir plus sur Signal Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!