Problem with fitting an experimental curve

1 view (last 30 days)
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

Accepted Answer

Rik
Rik on 9 Jun 2021
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)

More Answers (0)

Categories

Find more on Problem-Based Optimization Setup in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!