求解三个未知变量的三个方程的结果返回错误答案

时间:2017-02-11 16:04:10

标签: matlab math

我正在尝试用三个未知变量来解决三个方程组。

A1=((x+y)/2)+((x-y)/2*cos(2*phi))+(z*sin(2*phi))/2
A2=(x+y)/2-((x-y)/2)*cos(2*phi)-(z*sin(2*phi))/2
A3/2=(-(x-y)/2)*sin(2*phi)+(z*cos(2*phi))/2

其中A1,A2,A3和phi是已知的,x,y和z是未知的。我得到的结果却不正确,因为当我使用isequal查看时,它会给我0

这是代码

clear;
clc;
A1=50;
A2=37.5;
A3=125.6;
phi=-17.9;
syms x y z
eqn1 = (x+y)/2+(((x-y)/2)*cosd(2*phi))+(z*sind(2*phi))/2== A1;
eqn2 = (x+y)/2+(((x-y)/2)*cosd(2*phi))-(z*sind(2*phi))/2== A2;
eqn3 = ((-(x-y))/2*sind(2*phi))+((z/2)*cosd(2*phi))== A3/2;

[X, Y, Z] = solve(eqn1, eqn2, eqn3);
X = double(X);
Y = double(Y);
Z = double(Z);

AB=(X+Y)/2+(((X-Y)/2)*cosd(2*phi))+(Z*sind(2*phi))/2;
AC=(X+Y)/2+(((X-Y)/2)*cosd(2*phi))-(Z*sind(2*phi))/2;
AD=((-(X-Y)/2)*sind(2*phi))+((Z/2)*cosd(2*phi));

Z1=isequal(AB,A1);
Z2=isequal(AC,A2);
Z3=isequal(AD,A3/2);

0 个答案:

没有答案