如何用matlab回归计算参数,MATLAB用于三元回归参数 - 计算模拟 - 小木虫 - 学术 科研 互动社区...

function文件为下

function rcal = fun552(x,x1,x2)

for n=1:11%m为所取的数据点个数

R=8.315;

global x1 x2 x3 T;

tao12=x(1)./R/T(n);%x(1)=g12-g22

tao21=x(2)./R/T(n); %x(2)=g21-g11

tao13=x(3)./R/T(n); %x(3)=g13-g33

tao31=x(4)./R/T(n); %x(4)=g31-g11

tao23=x(5)./R/T(n); %x(5)=g23-g33

tao32=x(6)./R/T(n); %x(6)=g32-g22

tao=[tao12,tao13,tao21,tao23,tao31,tao32];

G=exp(-0.3*tao);

A(n)=(tao(3)*G(3)*x2(n)+tao(5)*G(5)*x3(n))/(x1(n)+G(3)*x2(n)+G(5)*x3(n));

B(n)=-x1(n)*(x2(n)*tao(3)*G(3)+x3(n)*tao(5)*G(5))/((x1(n)+G(3)*x2(n)+G(5)*x3(n))^2);

C(n)=x2(n)*G(1)*(tao(1)-(x1(n)*tao(1)*G(1)+x3(n)*tao(6)*G(6))/(G(1)*x1(n)+x2(n)+G(6)*x3(n)))/(G(1)*x1(n)+x2(n)+G(6)*x3(n));

D(n)=x3(n)*G(2)*(tao(2)-(x1(n)*tao(2)*G(2)+x2(n)*tao(4)*G(4))/(G(2)*x1(n)+G(4)*x2(n)+x3(n)))/(G(2)*x3(n)+G(4)*x2(n)+x3(n));

r1cal(n)=exp(A(n)+B(n)+C(n)+D(n));

A1(n)=(tao(1)*G(1)*x1(n)+tao(6)*G(6)*x3(n))/(G(1)*x1(n)+G(6)*x3(n)+x2(n));

B1(n)=-x2(n)*(x1(n)*tao(1)*G(1)+x3(n)*tao(6)*G(6))/((G(1)*x1(n)+x2(n)+G(6)*x3(n))^2);

C1(n)=x1(n)*G(3)/(x1(n)+G(3)*x2(n)+G(5)*x3(n))*(tao(3)-(x2(n)*tao(3)*G(3)+x3(n)*tao(5)*G(5))/(x1(n)+G(3)*x2(n)+G(5)*x3(n)));

D1(n)=x3(n)*G(4)/(G(2)*x1+G(4)*x2(n)+x3(n))*(tao(4)-(x1(n)*tao(2)*G(2)+x2(n)*tao(4)*G(4))/(G(2)*x1(n)+G(4)*x2(n)+x3(n)));

r2cal(n)=exp(A1(n)+B1(n)+C1(n)+D1(n));

rcal=[r1cal r2cal];

end

script文件如下

xx1=[0.05 0.105 0.153 0.248 0.347 0.446 0.474 0.535 0.624 0.740 0.870];%不含离子液体的x1

xx2=1-xx1;

x1=xx1/1.05;%离子液体浓度为5%

x2=xx2/1.05;

x3=1-x1-x2;

global x1 x2 x3 T;

y1=[0.397 0.483 0.521 0.601 0.635 0.676 0.685 0.713 0.745 0.825 0.897];

y2=1-y1;

T=[364 360.2 358.5 356.3 355.3 354.5 354.3 354.1 353.9 353.7 353.6];

t=T-273.15;

a=[7.23255 1750.286 235;7.16879 1552.601 222.419];

p1s=10.^(a(1,1)-a(1,2)./(t+a(1,3)));

p2s=10.^(a(2,1)-a(2,2)./(t+a(2,3)));

%A=7.23255; B=1750.286;C=235;

%A1=7.16879;B1=1552.601;C1=222.419;

%p1s=10.^(A-B./(t+C))

%p2s=10.^(A1-B1./(t+C1))

p3s=0;

%a为aotonie方程的三个系数

P=101.3%总压

r1exp=y1.*P./(x1.*p1s);

r2exp=y2.*P./(x2.*p2s);

rexp=[r1exp r2exp]

x0=[1,1,1,1,1,1];

xx=[xx1 xx1];

x=nlinfit(xx,rexp,'fun552',x0)

1704607_1333188807_646.png

最小二乘法 这个有问题 但不知道怎么改....

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值