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 CenterFile Exchange에서 Problem-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