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

조회 수: 9 (최근 30일)
Yasir
Yasir 2016년 3월 11일
답변: Steven Lord 2016년 3월 11일
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
Roger Stafford
Roger Stafford 2016년 3월 11일
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 2016년 3월 11일
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..

댓글을 달려면 로그인하십시오.

채택된 답변

Steven Lord
Steven Lord 2016년 3월 11일
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.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by