Why does this program return complex numbers?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using this code
to calculate the Itakura-Saito distance between two waveforms. When I used to it on several thousand different FFTs of the data it worked fine, however using it on the raw data produced results like "NaN -1.4918e+000i".
Looking at the code it seemed the NaNs were coming from any zeros in the input data as it divides by it. So I coded it to replace any zeros with 0.00001. This still leaves the complex numbers.
It's more down to application of theory then any coding errors but if someone could explain the reasoning behind it I'd be grateful.
0 commentaires
Réponses (1)
Babak
le 13 Août 2012
I think the complex numbers come from the function log used in your code at line 0064.
Note that the input of log function should be positive real number or it will give out a complex output! Check to see if the argument of log positive or not. In other words, if
r=pf1(1:nx,:)./pf2(1:nx,:);
is always positive.
0 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!