I'm trying to fit a line for a linear regression but I keep getting NaNs when using polyfit. I attached the data and the matlab files.

 채택된 답변

David Goodmanson
David Goodmanson 2020년 11월 21일
편집: David Goodmanson 2020년 11월 21일

0 개 추천

Hello TimaMarie,
yes, polyfit doesn't like NaNs. One way out is, just before doing polyfit, toss out the elements of both variables if either one of them is a NaN:
ind = isnan(con_WABA) | isnan(WAchl);
con_WABA(ind) = [];
WAchl(ind) = [];

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by