Using fit 'exp2' an error with "weights"

14 ビュー (過去 30 日間)
JJC
JJC 2013 年 4 月 12 日
コメント済み: Zahra Ali 2017 年 11 月 2 日
I've used the fit function a few times on creep data sets (i.e. time vs displacement) and have been using the 'exp2' fit type. On smaller data sets I've had no problem using this function. Now I'm looking at a 10 folder bigger data set and am getting an error.
I was previously running this and had no problem
[creep_data_fit, gof] = fit(creep_data(1:1800,1),creep_data(1:1800,2), 'exp2')
Now I'm running this and getting the following error
[creep_data_fit, gof] = fit(creep_data(1:10800,1),creep_data(1:10800,2), 'exp2')
Any ideas on why i'm getting this error?
Error using fit>iFit (line 235)
X, Y and WEIGHTS cannot have NaN values.
Error in fit (line 109)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...

回答 (2 件)

Tom Lane
Tom Lane 2013 年 4 月 13 日
Since you didn't specify weights, it seems like the NaN value must be in either x or y. You can find the usable values (using your own variable names) like this:
t = ~isnan(x) & ~isnan(y);
Then omit the NaN values from the fit:
fit(x(t),y(t),'poly1')
  1 件のコメント
Alison
Alison 2013 年 4 月 16 日
This worked great. Thanks Tom.

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


Alison
Alison 2013 年 4 月 16 日
This worked great thanks Tom!
  1 件のコメント
Zahra Ali
Zahra Ali 2017 年 11 月 2 日
I had been working on something similar for a very long time, thank you for your help!

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

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by