Mercurial > octave
view scripts/signal/sinc.m @ 904:3470f1e25a79
[project @ 1994-11-09 21:22:15 by jwe]
author | jwe |
---|---|
date | Wed, 09 Nov 1994 21:22:15 +0000 |
parents | 4e826edfbc56 |
children | 5cffc4b8de57 |
line wrap: on
line source
function result = sinc (x) # usage: sinc(x) # # Returns sin(pi*x)/(pi*x). # We either need to set the do_fortran_indexing variable to "true" # or use reshape to convert the input matrix to a vector, so that # we can use find to determine the elements of x that equal zero. # I prefer reshaping. [nr, nc] = size(x); nels = nr*nc; x = reshape(x,nels,1); # Set result to all ones initially. result = ones(nels,1); # Find non-zero elements in the input matrix. i = find(x); if (!isempty(i)) result(i) = sin(pi*x(i))./(pi*x(i)); endif result = reshape(result,nr,nc); endfunction