有六列数据,之间有相互关系,拟合关系为 y=a1*x1+a2*x2+a3*x3+a4*x4+a5/x5+a6
b=xlsread('data1.1.xlsx'); y=b(:,6); x = b(:,1:5); beta0=[1 1 1 1 1 1]'; fun=@(beta,x)x(:,1)*beta(1)+x(:,2)*beta(2)+x(:,3)*beta(3)+x(:,4)*beta(4)+(1./x(:,5))*beta(5)+beta(6); [beta,r,J]=nlinfit(x,y,fun,beta0)
coef0=ones(1,8); %fun=@(coef,x_v)(coef(1)*x_v(:,1)+coef(2)*x_v(:,2)+coef(3)*x_v(:,3)+coef(4))/(coef(5)*x_v(:,1)+coef(6)*x_v(:,2)+coef(7)*x_v(:,3)+coef(8)); x=[[-89.39151256059473,-137.02560212717475,294.21474132740184]; [-89.00640294668285,-136.43527900566508,292.94722809047147]; [-92.13506447504953,-141.23111160203118,303.2446077398585]; [-88.62171346838292,-135.845599897592,291.6810976480241]; [-90.46633114139622,-138.67315969716176,297.75229720565187]; [-88.2863231752905,-135.33149005044686,290.5772258653532]; [-93.44596784537251,-143.2405565538356,307.5591906902628]; [-90.22568043395219,-138.3042733549881,296.96024230454583]; [-89.2790025102939,-136.85313880323915,293.84443642486923]; [-94.15101574482283,-144.32130359774754,309.8797184385722]; [-95.83952722105414,-146.9095728316125,315.43712487434533]; [-88.91364351681958,-136.29309082285104,292.6419285057441]; [-86.79813484746683,-133.0502902378758,285.67914402989595]; [-92.65651132990632,-142.0304220423332,304.9608484334443]; [-91.38782426489834,-140.08568921464072,300.78521222409256]]; phi=[-89.39151256059473; -89.00640294668285; -92.13506447504953; -88.62171346838292; -90.46633114139622; -88.2863231752905; -93.44596784537251; -90.22568043395219; -89.2790025102939; -94.15101574482283; -95.83952722105414; -88.91364351681958; -86.79813484746683; -92.65651132990632; -91.38782426489834]; %testf(coef,[2,3,3]) coef=nlinfit(x,phi,testf,coef0); %coef=lsqnonlin('x,phi',coef0,x,phi);