clear,clc X=data; %input data y=X(:,3);x1=X(:,1);x2=X(:,2);X(:,3)=[]; fx=@(b,x1,x2)(b(1)+b(2)*x1+b(3)*x1.^2+b(4)*x2.^2+b(5)*x1.*x2+b(6)*x1.^3+b(7)*x1.^2.*x2)./(1+b(8)*x1+b(9)*x2+b(10)*x1.*x2); fx2=(b,X)(b(1)+b(2)*X(:,1)+b(3)*X(:,1).^2+b(4)*X(:,2).^2+b(5)*X(:,1).*X(:,2)+b(6)*X(:,1).^3+b(7)*X(:,1).^2.*X(:,2))./(1+b(8)*X(:,1)+b(9)*X(:,2)+b(10)*X(:,1).*X(:,2)); b =[1168.730503 -14.15105838 0.02775216681 0.0003288471733 -0.1784480235 -0.0004652991574 -6.404281467e-05 -0.01193583164 -2.78004198e-05 -0.0001515358185] for l=1:5 b=lsqcurvefit(fx2,b,X,y) b=nlinfit(X,y,fx2,b) end figure(1),clf plot3(x1,x2,y,'o') hold on [x11,x22]=meshgrid(min(x1):range(x1)/60:max(x1),min(x2):range(x2)/60:max(x2)); yhat=fx(b,x11,x22); surf(x11,x22,yhat); shading interp alpha(.8)
txt数据文件:https://pan.baidu.com/s/1uqJnfgg8Noy48IpEui1RaA 密码:875s
转:http://www.ilovematlab.cn/thread-483898-1-1.html