How to fit to data
1 view (last 30 days)
Show older comments
h=[0 0 0 0 0.03131 0.06654 0.11742 0.22701 0.3816 0.54012 0.67906 0.76712 0.85127 0.88845 0.91977 0.94912 0.96086 0.9726 0.98043 0.99022 0.99609 1 1];
k=[0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110];
kk=k';
hh=h';
F=@(q,x)q(1)-1/q(2)*(-1+1./x(:,2)+2*log(-1+1./x(:,2))-1./(-1+1./x(:,2)))-x(:,1)
x=[kk hh];
q0=[40 0.4000];
warning off
q=nlinfit(x,zeros(size(x,1),1),F,q0);
disp('k a分别为')
disp(num2str(q));
plot(x(:,1),x(:,2),'ro');
hold on;
ezplot(@(x,y)F(q,[x,y]),[0 120 0 1]);
2 Comments
Image Analyst
on 23 Dec 2019
What is x and what is y? Several of your h are the same as neighboring elements. That could be a problem. Try making them not the same. It looks like you're wanting to fit a sigmoid curve.
Answers (0)
See Also
Categories
Find more on Least Squares 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!