回复: nlinfit函数运行过程中问题
clear,clc
x=[0.2 1.5 0.401;0.2 1.0 0.401;0.2 0.5 0.401;0.2 0 0.478;0.2 -0.5 0.5832;
0.4 1.5 0.401;0.4 1.0 0.401;0.4 0.5 0.401;0.4 0 0.5638; 0.4 -0.5 0.6413;
0.7 1.5 0.401;0.7 1.0 0.401;0.7 0.5 0.401;0.7 0 0.7037;0.7 -0.5 0.6271;
0.9 1.5 0.501;0.9 1.0 0.602;0.9 0.5 0.401;0.9 0 0.6575;0.9 -0.5 0.8564];
y=x(:,3);x(:,3)=[];
fx=@(b,x)3./(1256*x(:,1).^2*sqrt(b(1)*b(2))).*exp(-(x(:,2)-10*b(2).*x(:,1)).^2/40*b(2).*x(:,1)).*exp(-10*b(3)*x(:,1));
b=[3.51, 0.0223, -0.4595];
for l=1:5
b=lsqcurvefit(fx,b,x,y);
b=nlinfit(x,y,fx,b);
end
bm=b
b=[3.5101555, 0.022290283, -0.4594986];
fxy=@(b,x1,x2)3./(1256*x1.^2*sqrt(b(1)*b(2))).*exp(-(x2-10*b(2).*x1).^2/40*b(2).*x1).*exp(-10*b(3)*x1);
x1=x(:,1);x2=x(:,2);n=length(y);
str=num2str([1:n]');
[x11,x22]=meshgrid(min(x1):range(x1)/60:max(x1),min(x2):range(x2):max(x2));
y1=fxy(b,x11,x22);
plot3(x1,x2,y,'o')
stem3(x1,x2,y,'filled')
text(x1,x2,y,str,'fontsize',12)
hold on
surf(x11,x22,y1);
shading interp
alpha(.85)
axis tight
结果见生成的图。可见,该组数据用此模型来描述是不恰当的,必须修改该或采用另外的模型。
|