Inverse tangent inaccuracy?

3 Ansichten (letzte 30 Tage)
Robert Waechter
Robert Waechter am 4 Nov. 2017
Kommentiert: Robert Waechter am 4 Nov. 2017
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!

Akzeptierte Antwort

David Goodmanson
David Goodmanson am 4 Nov. 2017
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 Kommentar
Robert Waechter
Robert Waechter am 4 Nov. 2017
I knew it must've been something simple like that. Thanx!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Fluid Dynamics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by