polyfit returns NaN values in p
이전 댓글 표시
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?
채택된 답변
추가 답변 (1개)
carlo lefevre
2015년 12월 9일
0 개 추천
ind = 1:length(a); k = ~isnan(a); p = polyfit(ind(k),a(k),n)
댓글 수: 1
Steven Lord
2015년 12월 9일
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.)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!