home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
octave-1.1.1p1-src.tgz
/
tar.out
/
fsf
/
octave
/
scripts
/
signal
/
sinc.m
< prev
Wrap
Text File
|
1996-09-28
|
611b
|
31 lines
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