matlab解三元一次方程组问题,求大神帮忙。

2024-12-19 20:06:59
推荐回答(1个)
回答1:

给出的三元一次方程组,应该用fsolve()函数来求解。实现代码如下:

x0=[-0.75127  -0.2551 -0.50596];

[x,fval] = fsolve(@exfun,x0)

exfun——自定义三元一次方程组函数

function y=exfun(x)

u=x(1);v=x(2);a=x(3);

LA=1.203;

LB=0.6054;

LC=1.203;

S1 = (u^2+v^2*cos(a))/(u^2+v^2);

S2 = (u*v*(1-cos(a)))/(u^2+v^2);

S3 = (v^2+u^2*cos(a))/(u^2+v^2);

S4 = (v*sin(a))/((u^2+v^2)^0.5);

S5 = (u*sin(a))/((u^2+v^2)^0.5);

y(1)=((-1)*1.65*S1+(-1)*0.6*S2-(-1)*1.65)^2+((-1)*1.65*S2+(-1)*0.6*S3-(-1)*0.6)^2+((-1)*1.65*S4+(-1)*0.6*S5+0.9)^2-(LA)^2;

y(2)=((-1)*1.65*S1+0.6*S2-(-1)*1.65)^2+((-1)*1.65*S2+0.6*S3-0.6)^2+((-1)*1.65*S4+0.6*S5+0.9)^2-(LB)^2;

y(3)=(1.65*S1+(-1)*0.6*S2-1.65)^2+(1.65*S2+(-1)*0.6*S3-(-1)*0.6)^2+(1.65*S4+(-1)*0.6*S5+0.9)^2-(LC)^2;

end

运行结果

x =      -0.4103  -1.7029e-05      0.52412

fval =   1.2744e-05  -0.00030638  -0.00014883

即u=-0.4103; v=-1.7029e-05; a=0.52412