Problem with fitting an experimental curve
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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])
y_fit=f.k.*x.^f.n;
plot(x,y),hold on
plot(x,y_fit)
0 Comments
More Answers (0)
See Also
Categories
Find more on Problem-Based Optimization Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!