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.

 Akzeptierte Antwort

David Goodmanson
David Goodmanson am 21 Nov. 2020
Bearbeitet: David Goodmanson am 21 Nov. 2020

0 Stimmen

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) = [];

Weitere Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by