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 CenterFile Exchange에서 Fluid Dynamics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by