フィルターのクリア

Library function log10 not found when using fit

30 ビュー (過去 30 日間)
Sean Morgan
Sean Morgan 2024 年 5 月 22 日
コメント済み: Steven Lord 2024 年 5 月 23 日
I have been trying to fit some data using a lograthimic fit with the following command, where ind_array and sample_array are my x and y data respectively:
expo_curve=fit(ind_array,sample_array,'log10');
However, I keep getting the following error:
Library function log10 not found.
The weird thing is I was using this exact code like 3 weeks ago and was able to generate the fit. So I am unsure what is going wrong, and the API says that 'log10' is a valid fittype for the fit command.
Any help would be appreciated,
Thank you,
Sean

採用された回答

John D'Errico
John D'Errico 2024 年 5 月 23 日
編集済み: John D'Errico 2024 年 5 月 23 日
x = rand(10,1);y = x + rand(10,1);
fit(x,y,'log10')
ans =
Linear model Log10: ans(x) = a*log10(x) + b Coefficients (with 95% confidence bounds): a = 0.5735 (0.1061, 1.041) b = 1.279 (0.9743, 1.584)
It is almost always, ALWAYS the case that when this happens, you were previously using a different, more recent MATLAB release.
As you can see above, it does work. But, to be honest, I did not recall that being one of the valid fit types. So I tried it on my computer, and it failed, using R2023a.
And that means they just introduced that option. So you were possibly using an online MATLAB, or a new release on some other computer. But today, you were using an older release, and the option did not exist then. They must have alloed that option in only the last year. I could check the release notes, but I am sure that is the case.
What can you do? Well, make sure your version is a sufficiently recent one. Otherwise, you could use a custom fittype of that form. For example, this would work, even in an older release:
mdl = fittype('a*log10(x) + b',indep = 'x')
mdl =
General model: mdl(a,b,x) = a*log10(x) + b
fittedmdl = fit(x,y,mdl)
Warning: Start point not provided, choosing random start point.
fittedmdl =
General model: fittedmdl(x) = a*log10(x) + b Coefficients (with 95% confidence bounds): a = 0.5735 (0.1061, 1.041) b = 1.279 (0.9743, 1.584)
Note that because the model is actually linear in the parameters, fit was smart enough to not bother needing starting values for the 'log10' option.
  3 件のコメント
John D'Errico
John D'Errico 2024 年 5 月 23 日
Been there, done that. I tend to keep old releases around, only discarding them when they get 4 or 5 deep. Sometimes it is useful to have an older one, to test some code that someone has an issue with. But the problem is I sometimes end up using one of the older ones by accident.
Steven Lord
Steven Lord 2024 年 5 月 23 日
The Release Notes confirm that the ability to specify logarithmic fit types was introduced in Curve Fitting Toolbox in release R2023b.

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

その他の回答 (1 件)

Kunal Kandhari
Kunal Kandhari 2024 年 5 月 22 日
Since it worked previously, you may have a path problem.
Run these from a script or your Command Window:
restoredefaultpath
rehash toolboxcache
rehash path
savepath
Then run your code again.
  2 件のコメント
Sean Morgan
Sean Morgan 2024 年 5 月 23 日
編集済み: Sean Morgan 2024 年 5 月 23 日
Thanks for the help,
Unfortuneatly I am still getting the same error after doing what you suggested. Do you have any other ideas?
Also, this is probably related, but I don't seem to have a logarithmic fit type in the curve fitting app either (see screenshot).
Thanks,
Sean
John D'Errico
John D'Errico 2024 年 5 月 23 日
No. That would never be a path issue.

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

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by