How can I get the "zero" value of cosine function in radians??

9 visualizzazioni (ultimi 30 giorni)
Due to the approximations and radian values used by MATLAB, I can't get "zero" value of cosine function. "acos(0)" gives answer of 1.5708 radians, but Cos(1.5708) doesn't lead to "zero". Can anyone help??
  2 Commenti
Roger Stafford
Roger Stafford il 11 Mar 2016
Please show us your actual computations. You are only showing values in 'format short' here which is not very accurate. Expressed to greater accuracy the arc-cosine of zero would for example be 1.570796327
Yasir
Yasir il 11 Mar 2016
clc clear all
v1=1; v2=1; v3=1; s1=0; s2=0; s3=0;
z12=0.08j ; z13=0.04j; z23=0.01j; y12=1/z12; y13=1/z13; y23=1/z23;
Y11=y13+y12 ; Y12= -y12 ; Y13=-y13; Y21= -y12 ; Y22=y12+y23; Y23=-y23; Y31= -y13 ; Y32= -y23 ; Y33=y23+y13;
A=[Y11 Y12 Y13; Y21 Y22 Y23; Y31 Y32 Y33]
O=angle (A) Y=abs (A)
P2=v2*v1*Y(2,1)*cos(O(2,1)-s2+s1)+v2*v2*O(2,2)*cos(O(2,2))+v2*v3*Y(2,3)*cos(O(2,3)-s2+s3)
P2 should give output of zero..

Accedi per commentare.

Risposta accettata

Steven Lord
Steven Lord il 11 Mar 2016
Use the degree-based trig functions or Symbolic Math Toolbox.
d = acosd(0);
cosd(d)
ds = acos(sym(0));
cos(ds)
There's a brief discussion of this sort of scenario [where cos(pi/2) is close to, but not exactly equal to, 0] in the Cleve's Corner article from February 2002 that you might find informative.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by