6239
|
1 ## Copyright (C) 2006 David Bateman <dbateman@free.fr> |
|
2 ## |
|
3 ## This program is free software; you can redistribute it and/or modify |
|
4 ## it under the terms of the GNU General Public License as published by |
|
5 ## the Free Software Foundation; either version 2 of the License, or |
|
6 ## (at your option) any later version. |
|
7 ## |
|
8 ## This program is distributed in the hope that it will be useful, |
|
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 ## GNU General Public License for more details. |
|
12 ## |
|
13 ## You should have received a copy of the GNU General Public License |
|
14 ## along with this program; if not, write to the Free Software |
|
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
16 |
|
17 ## -*- texinfo -*- |
|
18 ## @deftypefn {Function File} {} sind (@var{x}) |
|
19 ## Compute the sine of each element of @var{x}. Returns zero in elements |
|
20 ## for which @code{@var{x}/180} is an integer. |
|
21 ## @seealso{sin, cosd, tand, acosd, asind, atand} |
|
22 ## @end deftypefn |
|
23 |
|
24 function y = sind (x) |
|
25 if (nargin != 1) |
|
26 print_usage (); |
|
27 endif |
|
28 I = x / 180; |
|
29 y = sin (I .* pi); |
|
30 y(I == round (I) & finite (I)) = 0; |
|
31 endfunction |
|
32 |
|
33 %!error(sind()) |
|
34 %!error(sind(1,2)) |
|
35 %!assert(sind(10:10:90),sin(pi*[10:10:90]/180),-10*eps) |
|
36 %!assert(sind([0,180,360]) == 0) |
|
37 %!assert(sind([90,270]) != 0) |