matlab解三元一次方程组问题,求大神帮忙。
syms u v a ;
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);
eq1 = @(u,v,a)((-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;
eq2 = @(u,v,a)((-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;
eq3 = @(u,v,a)(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;
[u,v,a] = solve(eq1,eq2,eq3,'u','v','a');
matlab的计算结果是:
>> Untitled3
警告: Cannot find explicit solution.
> In solve at 319
In Untitled3 at 14
>> a
a =
Empty sym: 0-by-1
但是a的值解出来应该在0.5236左右,不知道那边出错了,恳求大神指导一下。 展开
给出的三元一次方程组,应该用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
广告 您可能关注的内容 |