Integration of function containing if-test
Francesco Potortì
Potorti at isti.cnr.it
Thu Feb 5 19:05:44 CST 2009
>I have a function nu(x) that is defined using an if-test. It has a
>special value (0) at x = 0, and is defined in terms of an ordinary
>function f(x) everywhere else. Therefore I have:
>
>function y = nu(x)
> if (x == 0)
> y = 0;
> else
> y = f(x);
> endif
>endfunction
>
>When I pass it a 0 it returns a zero. But when I pass it a vector [0 1]
>it doesn't work
If the function f works with vectors, then:
function y = nu(x)
y = zeros (size (x));
notzero = x(x != 0);
y(notzero) = f (x(notzero));
endfunction
--
Francesco Potortì (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa Email: Potorti at isti.cnr.it
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/
More information about the Help-octave
mailing list