Inverse tangent inaccuracy?

3 ビュー (過去 30 日間)
Robert Waechter
Robert Waechter 2017 年 11 月 4 日
コメント済み: Robert Waechter 2017 年 11 月 4 日
I wrote a program to calculate the open and crossed angle values of a four bar mechanism and everything seems to work fine until I get to the final calculation in which I try to take the inverse tangent of the quadratic equation and the resulting answers are incorrect. Here is my code.
L1=6;
L2=2;
L3=7;
L4=9;
theta2=30*(pi/180);
a=L2;
b=L3;
c=L4;
d=L1;
K1=d/a;
K2=d/c;
K3=(a^2-b^2+c^2+d^2)/(2*a*c);
K4=d/b;
K5=(c^2-d^2-a^2-b^2)/(2*a*b);
A=cos(theta2)-K1-(K2*cos(theta2))+K3;
B=-2*sin(theta2);
C=K1-((K2+1)*cos(theta2))+K3;
D=cos(theta2)-K1+(K4*cos(theta2))+K5;
E=B;
F=K1+((K4-1)*cos(theta2))+K5;
theta4a=2*(atand(-B+sqrt((B^2)-(4*A*C))/(2*A)))
theta4b=2*(atand(-B-sqrt((B^2)-(4*A*C))/(2*A)))
theta3a=2*(atand(-E+sqrt((E^2)-(4*D*F))/(2*D)))
theta3b=2*(atand(-E-sqrt((E^2)-(4*D*F))/(2*D)))
The values I get for answers are:
theta4a = -106.6958
theta4b = 146.7016
theta3a = -31.0711
theta3b = 132.5987
The resulting correct answers should be:
theta4a = -143.67
theta4b = 117.32
theta3a = -115.21
theta3b = 88.84
I can't seem to find the problem any help would be appreciated. Thanx!

採用された回答

David Goodmanson
David Goodmanson 2017 年 11 月 4 日
Hi Robert,
All you need do is replace the expression for theta4a by
theta4a = 2*atand((-B +sqrt((B^2)-(4*A*C)))/(2*A))
and similarly for the other three. You forgot that 2A divides -B as well as the sqrt term.
  1 件のコメント
Robert Waechter
Robert Waechter 2017 年 11 月 4 日
I knew it must've been something simple like that. Thanx!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFluid Dynamics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by