Mercurial > hg > octave-lyh
annotate scripts/signal/sinc.m @ 11188:4cb1522e4d0f
Use function handle as input to cellfun,
rather than quoted function name or anonymous function wrapper.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 03 Nov 2010 17:20:56 -0700 |
parents | f0c3d3fc4903 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 1994, 1996, 1997, 1999, 2000, 2004, 2005, 2007, 2009 |
7017 | 2 ## John W. Eaton |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
2303 | 19 |
3367 | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function File} {} sinc (@var{x}) | |
22 ## Return | |
23 ## @tex | |
24 ## $ \sin (\pi x)/(\pi x)$. | |
25 ## @end tex | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7125
diff
changeset
|
26 ## @ifnottex |
3367 | 27 ## sin(pi*x)/(pi*x). |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7125
diff
changeset
|
28 ## @end ifnottex |
3367 | 29 ## @end deftypefn |
559 | 30 |
3367 | 31 ## Author: jwe ??? |
2314 | 32 |
2311 | 33 function result = sinc (x) |
559 | 34 |
7125 | 35 if (nargin != 1) |
36 print_usage (); | |
37 endif | |
38 | |
3486 | 39 result = ones (size (x)); |
559 | 40 |
3486 | 41 i = (x != 0); |
559 | 42 |
4807 | 43 if (any (i(:))) |
3486 | 44 t = pi * x(i); |
45 result(i) = sin (t) ./ t; | |
559 | 46 endif |
47 | |
48 endfunction |