Problem with fitting an experimental curve
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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])
y_fit=f.k.*x.^f.n;
plot(x,y),hold on
plot(x,y_fit)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!