x0=[10,0.5,1]
x=leastsq('ct',x0)
tt=0:1:16
yy=x(1).*(exp(-x(2).*tt-exp(-x(3).*tt)))
plot(tt,yy,'g')
hold on
t=[0.25 0.5 0.75 1 1.5 2 2.5 3 3.5 4 4.5 5 6 7 8 9 10 11 12 13 14 15 16];
c=[30 68 75 82 82 77 68 68 58 51 50 41 38 35 28 25 18 15 12 10 7 7 4];
plot(t,c,'*')
function y=ct(x)
t=[0.25 0.5 0.75 1 1.5 2 2.5 3 3.5 4 4.5 5 6 7 8 9 10 11 12 13 14 15 16];
c=[30 68 75 82 82 77 68 68 58 51 50 41 38 35 28 25 18 15 12 10 7 7 4];
y=c-x(1)*(exp(-x(2)*t)-exp(-x(3)*t))
运行后
x0 =
10.0000 0.5000 1.0000
??? Undefined function or method 'leastsq' for input arguments of type 'char'.
x=leastsq('ct',x0)
tt=0:1:16
yy=x(1).*(exp(-x(2).*tt-exp(-x(3).*tt)))
plot(tt,yy,'g')
hold on
t=[0.25 0.5 0.75 1 1.5 2 2.5 3 3.5 4 4.5 5 6 7 8 9 10 11 12 13 14 15 16];
c=[30 68 75 82 82 77 68 68 58 51 50 41 38 35 28 25 18 15 12 10 7 7 4];
plot(t,c,'*')
function y=ct(x)
t=[0.25 0.5 0.75 1 1.5 2 2.5 3 3.5 4 4.5 5 6 7 8 9 10 11 12 13 14 15 16];
c=[30 68 75 82 82 77 68 68 58 51 50 41 38 35 28 25 18 15 12 10 7 7 4];
y=c-x(1)*(exp(-x(2)*t)-exp(-x(3)*t))
运行后
x0 =
10.0000 0.5000 1.0000
??? Undefined function or method 'leastsq' for input arguments of type 'char'.