|
要拟和的数据为
x = 3.9900 9.9900 16.3900 22.7900 29.1900 35.1900 41.5900
47.9900 53.9900 60.3900 66.7900 72.7900 79.1900 85.5900
91.9900 97.9900
y = 2.1634 2.9223 4.0168 5.4091 7.0874 9.2672 11.6971
13.8987 15.9450 17.5862 18.4444 18.9926 19.5583 19.7022
19.5028 19.8513
拟和出曲线y=1/(c+a*exp(b*x))
funtion f=myfun(a,x)
f=1./(a(3)+a(1)*exp(a(2)*x));
x = [3.9900 9.9900 16.3900 22.7900 29.1900 35.1900 41.5900...
47.9900 53.9900 60.3900 66.7900 72.7900 79.1900 85.5900...
91.9900 97.9900];
y=[2.1634 2.9223 4.0168 5.4091 7.0874 9.2672 11.6971...
13.8987 15.9450 17.5862 18.4444 18.9926 19.5583 19.7022...
19.5028 19.8513];
a0=[1 -.1 1];
options=optimset('MaxFunEvals',1000000);
options=optimset('MaxIter',1000000);
[a,residual]=lsqcurvefit(@myfun,a0,x,y,[],[],options)
plot(x,y,'o')
hold on
plot(x,1./(a(3)+a(1)*exp(a(2)*x)))
解得
a =
0.7546 -0.0740 0.0493
residual =
1.2527
其中a(1)为a,a(2)为b,a(3)为c
GMT+8, 2024-11-5 18:45 , Processed in 0.037378 second(s), 16 queries , Gzip On.
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.