polyfit returns NaN values in p
Afficher commentaires plus anciens
I want to do a linear regression on the response Y (attached)with a predictor vector X. Therefore, I used Matlab polyfit function: [p,s,mu]=polyfit(X,Y,1) but it returns p=[NaN,Inf]
I have Inf values in vector Y. Is it the cause?
Réponse acceptée
Plus de réponses (1)
carlo lefevre
le 9 Déc 2015
0 votes
ind = 1:length(a); k = ~isnan(a); p = polyfit(ind(k),a(k),n)
1 commentaire
Steven Lord
le 9 Déc 2015
You probably want to use ISFINITE instead of ~ISNAN to include only finite values (excluding Inf, -Inf, and NaN) rather than including only non-NaN values (which would NOT exclude Inf or -Inf.)
Catégories
En savoir plus sur Images 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!