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

1 件のコメント

TinaMarie Haskell
TinaMarie Haskell 2020 年 11 月 21 日
Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLinear and Nonlinear Regression についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by