curvefiteg1.m

来自「matlab高级统计工具箱」· M 代码 · 共 18 行

M
18
字号
 % script leasq example using curvefit
% generate some data
t=[0.:.01:1]';
p=[4 5];
y=exp(-p(1)*t).*sin(2*pi*p(2)*t);
yd=y+.01*randn(size(y));  %add noise
p0=[2	3];	  %initial guess for paprameters
[pfinal,options,error,jac]=curvefit('modelcurve',p0,t,yd);
pfinal
ymodel=yd+reshape(error,size(yd));% error vector needs reshaping

% calc regression data
[std,varresid,r2,cor,vcv,varinf]=regdata(pfinal,ymodel,yd,jac);
figure
plot(t,ymodel,t,yd,'o')
grid
xlabel('time t');ylabel('y ')
title('fitted - , vs data o')

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?