# is matlab 'fit' function changing behavior ?

6 ビュー (過去 30 日間)
Neha Shaah 2022 年 11 月 2 日
コメント済み: Xingzheng Pan 2022 年 12 月 8 日
I was working with curve fitting problem and use fit function as follows :
Now when I am running the code after 2 days, an error pops us saying there are more inputs than expected and correct syntax should be
fit(mdl,data)
I see that the second fit function was introduced in r2022b. does that mean the first fit function from curve fitting toolbox is getting replaced with something else ? If yes, what alternatives can I use in r2022b ?

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

### 採用された回答

Hiro Yoshino 2022 年 11 月 2 日
There are actually many "fit" functions avaiable within MATLAB.
MATLAB determines which "fit" function to use based on the types and the combinations of the input arguments.
For example, the fit provided by Curve Fitting Toolbox is called this way:
f=fit(cdate,pop,'poly2')
f =
Linear model Poly2: f(x) = p1*x^2 + p2*x + p3 Coefficients (with 95% confidence bounds): p1 = 0.006541 (0.006124, 0.006958) p2 = -23.51 (-25.09, -21.93) p3 = 2.113e+04 (1.964e+04, 2.262e+04)
plot(f,cdate,pop)
whereas, the one provided by Predictive Maintenance Toolbox is:
fit(mdl,linTrainVectors)
mdl
mdl =
linearDegradationModel with properties: Theta: 0.4982 ThetaVariance: 0.0124 SlopeDetectionLevel: 0.0500 Prior: [1×1 struct] NoiseVariance: 0.9920 SlopeDetectionInstant: [] CurrentMeasurement: 0 Phi: 2.5204 InitialLifeTimeValue: [] CurrentLifeTimeValue: [] LifeTimeVariable: "" LifeTimeUnit: "" DataVariables: "" UserData: [] UseParallel: 0
I suppose the function that is available most among the toolboxes is "plot". You can find many plot functions.

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

### その他の回答 (1 件)

Xingzheng Pan 2022 年 12 月 7 日
Hey all. I still get trouble even use the demo case above. The Matlab still call the fit function in ML toolbox, any ideas to deactivate? I really need the fit function in curve fitting toolbox.
##### 2 件のコメント表示非表示 1 件の古いコメント
Xingzheng Pan 2022 年 12 月 8 日
Yeh mate. All fixed now. I realised I don't have curve fitting toolbox installed before.
Have a good day.

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

### カテゴリ

Find more on Predict Remaining Useful Life in Help Center and File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!

Translated by