辛苦几天收集的资料:
1.使用“nlinfit”
x1=1150,1000,900,850,700,625,550,475,3350,3500,5900,5800,5700,4600,4625,4725,11650,11200,11200]';
x2=[175,100,25,0,75,100,150,200,50,600,500,225,100,1225,1600,2000,1200,1000,1550
]';
x=[x1,x2];
y=[1.44E-02,1.80E-02,6.08E-02,5.59E-02,3.42E-02,7.74E-03,1.17E-03,6.16E-03,1.91E-04,1.91E-04,1.02E-03,2.83E-03,9.52E-05,3.77E-04,2.70E-04,1.87E-04,3.98E-04,4.04E-04,4.02E-04]';
beta0=[0.1 0.1 1 1];
myfun=@(a,x)4030.0./pi./4.2./(a(1).*x(:,1).^a(2).*a(3).*x(:,1).^a(4)).*exp(-(x(:,2).^2./2./(a(1).*x(:,1).^a(2)).^2+30.0.^2./2./(a(3).*x(:,1).^a(4)).^2));
[a,b,c,d,res]=nlinfit(x,y,myfun,beta0);a,res
plot3(x1,x2,y,'o',x1,x2,myfun(a,x))
值的选取没有定法,与实际问题的模型有关。
2.使用“regress”
线性的不行,用二次函数。
formatlong
A=[...
0.213.6850325127.47.79.9365831413.95.810.8730743326.87.709.70671725723.87.59.8760928021.75.611.3427153314.66.27.652169482253.239.16165168044.10.3311.3173668554.10.149.5142459156.65.59.718184331.62.38.933612250114.93.34.67392751661.99.732175150107.50.69.933088242142.30.2211.71862056760.41.8811.762788526771.62.7810.9217807658.7]
x=A(:,1:4),Y=A(:,5)
x11=x(:,1).*x(:,1);
x12=x(:,1).*x(:,2);
x13=x(:,1).*x(:,3);
x14=x(:,1).*x(:,4);
x22=x(:,2).*x(:,2);
x23=x(:,2).*x(:,3);
x24=x(:,2).*x(:,4);
x33=x(:,3).*x(:,3);
x34=x(:,3).*x(:,4);
x44=x(:,4).*x(:,4);
X=[x(:,:),x11,x12,x13,x14,x22,x23,x24,x33,x34,x44]
[B,BINT,R]=REGRESS(Y,[ones(length(Y),1),X])结果:
B=
1.0e+003*
-1.426098928217992
-0.004076772421011
0.255534919787513
0.000012942581436
0.000845938681439
0.000607150442496
-0.000574488595437
0.000000405451807
-0.000042626483419
-0.011775830339062
-0.000000876232149
0.000008150156703
-0.000000000013441
-0.000000013991054
-0.000000969496753
R=
3.122573422039807
0.447341267999400
-7.343326306615449
2.107836742251767
-6.239492394117182
9.044235126157025
2.238791755625499
4.285551199892858
-2.231536057549363
-1.979307925154075
3.503835830046878
1.414933242530537
-1.426757776398972
-12.05973319576
14.597045597468522
-5.024612350970848
-1.747668123505179
-2.717435276394376
B就是系数,R就是预测值与实际值的差值。
3. 使用“lsqcurvefit”
clear
clc
x=[40506070809010011015150];
y=[0.00960.01450.01940.03480.05010.07510.10000.14970.19930.24960.2999];
z=[0.24000.28650.33300.36000.38700.40100.41500.43900.46300.48750.5120];
X0=[1 1 1 1 1 1];
%只要这样写就可以了
f=@(p,x)( p(1) + p(2)*x(1,:) +
p(3)*x(2,:) + p(4)*x(1,:).^2 + p(5)*x(1,:).*x(2,:) +
p(6)*x(2,:).^2);
p=lsqcurvefit(f,X0,[x;y],z)