Problem with fitting an experimental curve

1 回表示 (過去 30 日間)
Pricci Alessio
Pricci Alessio 2021 年 6 月 9 日
回答済み: Rik 2021 年 6 月 9 日
Hello everyone,
I'm trying to fit an experimental curve, described by the attached 'Data001.mat', with an analytical expression of the form:
y=k*x^n
where 'x' is the vector of abscissae in Data001 (first column of the mat file; I'm attaching a graphical representation of the data contained in Data001, named as 'exp.png', so to be more clear). In the analytical expression, both k and n are the parameters that I want to determine, so that the analytically calculated vector 'y' matches to the best the second column of the .mat file Data001.
Hope to hear from you soon.
Best regards,
A

採用された回答

Rik
Rik 2021 年 6 月 9 日
Your function doesn't fit the data well. You should probably consider using an offset term as well.
S=load(websave('data.mat','https://www.mathworks.com/matlabcentral/answers/uploaded_files/647220/Data001.mat'));
x=S.Data001(:,1);
y=S.Data001(:,2);
f=fit(x,y,@(k,n,x)k.*x.^n,'start',[-1,1])
f =
General model: f(x) = k.*x.^n Coefficients (with 95% confidence bounds): k = 7e+05 (-2.835e+04, 1.428e+06) n = -0.4585 (-0.5573, -0.3598)
y_fit=f.k.*x.^f.n;
plot(x,y),hold on
plot(x,y_fit)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by