%方法一
y=[50 40 30 20 10 ]; t=[55 63 73 100 121];
yp=log(y);
p = polyfit(t,yp,1);
b=-p(1)
a=exp(p(2))
yf=a*exp(-b*t);
yf-y
plot(t,y,'r+',t,yf,'b-')
legend('原始点','拟合线')
%方法二
%% Fit: 'exp1'.
[xData, yData] = prepareCurveData( t, y );
% Set up fittype and options.
ft = fittype( 'exp1' );
opts = fitoptions( ft );
opts.StartPoint = [145.2 -0.3];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'y vs. t', 'exp1', 'Location', 'NorthEast' );
% Label axes
xlabel( 't' );
ylabel( 'y' );
fitresult
gof
%方法三
y=[50 40 30 20 10 ]';
yp=log(y);
t=[55 63 73 100 121]';
tl=ones(size(t));
t1=[tl t];
p=t1\yp;
b=-p(2)
a=exp(p(1))
yf=a*exp(-b*t);
yf-y
plot(t,y,'r+',t,yf,'b-')
legend('原始点','拟合线')
%方法四
regress
追问你好,能把那个曲线的未知系数求出来吗?程序,再次感谢
追答你拟合的目的就是求出a和b,每个程序都能求出来的。
b =
0.0229
a =
172.2620
本回答被提问者采纳