Why do I get an error with the fit function even though I'm following at MATLAB tutorial?

2 ビュー (過去 30 日間)
I am trying to learn how to use the fit function by using the following example code from MATLAB:
x = (0:0.2:5)';
y = 2*exp(-0.2*x) + 0.1*randn(size(x));
f = fit(x,y,'exp1')
However, I keep receiving this error message:
Check for missing argument or incorrect argument
data type in call to function 'fit'.
Error in test (line 3)
f = fit(x,y,'exp1')
I am almost 100% sure the code works fine, so I think something else is causing this. Is the fit function outdated? Based on the error message, I would think that there might be another copy of fit.m on my computer that I am unaware of, but I couldn't find anything. Thanks!

採用された回答

Kevin Yeung
Kevin Yeung 2020 年 6 月 27 日
I figured it out! I simply forgot to install the Curve Fitting Toolbox. Thanks anyways!

その他の回答 (1 件)

madhan ravi
madhan ravi 2020 年 6 月 27 日
Works fine for me. Probably you made a custom file fit.m .
which fit -all % what does it show?
  1 件のコメント
Kevin Yeung
Kevin Yeung 2020 年 6 月 27 日
This comes up:
C:\Program Files\MATLAB\R2020a\toolbox\stats\stats\@gmdistribution\fit.m % gmdistribution method

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

カテゴリ

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