polyfit returns NaN values in p
Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (1)
carlo lefevre
el 9 de Dic. de 2015
0 votos
ind = 1:length(a); k = ~isnan(a); p = polyfit(ind(k),a(k),n)
1 comentario
Steven Lord
el 9 de Dic. de 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.)
Categorías
Más información sobre Images en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!