Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB sin() vs sind()

I noticed that MATLAB has a sin() and sind() functions. I learnt that sin() accepts the angle in radians and sind() accepts the angle in degrees. The only difference I know is sind(180) gives 0 but sin(pi) doesn't:

>> sin(pi)
ans =
  1.2246e-016
>> sind(180)
ans =
     0

What boggles me is whether there is any scenarios or guidelines to choose between using sin() or sind()?

like image 943
barney Avatar asked Oct 17 '13 07:10

barney


1 Answers

From the documentation of sind:

For integers n, sind(n*180) is exactly zero, whereas sin(n*pi) reflects the accuracy of the floating point value of pi.

So, if you are extremely troubled with the fact that sin( pi ) is not precisly zero, go ahead and use sind, but in practice it is just a wrap-around sin so you actually add a tini-tiny bit of overhead.

Personally, I prefer the elegance of radians and use sin.

like image 121
Shai Avatar answered Sep 20 '22 22:09

Shai