如题,本人想求matlab nlinfit 拟合的参数的标准误,请各位高抬贵手帮帮我,谢谢大家了!
fun1.m文件:如下
function ydata=fun1(p,xdata)
ydata=p(1)*exp(1+((p(2)-xdata)./p(3))-exp((p(2)-xdata)./p(3)));
% xdata,ydata 为实验所得数据;p( )为参数
Command Window 输入初始数据:
clear
%输入实验数据 xdata,ydata
xdata=[18 21 24 27 30 33]
ydata=[0.6470 0.8167 0.8915 0.8499 0.8312 0.7978 ]
%设定迭代初始值Parameters0,分别代表a,b,c,
Parameters0 =[0.95,28,20] ;
[Parameters, r, j ] = nlinfit ( xdata, ydata, 'fu1',Parameters0)

 채택된 답변

0 개 추천

clear,clc
x=[18 21 24 27 30 33]';
y=[0.6470 0.8167 0.8915 0.8499 0.8312 0.7978 ]';
fx=@(p,xdata)p(1)*exp(1+((p(2)-xdata)./p(3))-exp((p(2)-xdata)/p(3)));
p=[0.95,20,20];%0.8843 26.1995 12.1929];
n=length(y);
for l=1:5
p=lsqcurvefit(fx,p,x,y)
p=nlinfit(x,y,fx,p)
end
[p,r,j]=nlinfit(x,y,fx,p);
figure(1),clf
plot(x,y,'o','markerfacecolor','k')
hold on
x1=linspace(min(x),max(x),200);
y1=fx(p,x1);
plot(x1,y1,'r-','linewidth',2.5)
axis tight
c=inv(j'*j);
SSy=var(y)*(n-1);
yhat=fx(p,x);
RSS=(y-yhat)'*(y-yhat); % residual sum of squares
MSe=RSS/(n-3-1), %mean squares of residuals
rsquare=(SSy-RSS)/SSy,%determinant coefficeient
sp=sqrt(MSe*diag(c)'), % standard error of p
t=p./sp, % t value
数据点太少,误差估计不合适,结果难以为据。

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB 快速入门에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!