I would like to code the following function:
$$f(x)=\begin{cases} \dfrac{\sin(x)}{x} & x\neq 0 \\ 1 & x = 0. \end{cases} $$
I am doing the following:
f = @(x) (sin(x)./x.*(x~=0) + 1.*(x==0));
However, f(0)returns NaN, while it must return 1.
Do you see what I am missing? Thanks
isnanin unnamed functions without the need to useif-elsestatement in a function file. – GNUSupporter 8964民主女神 地下教會 Feb 08 '18 at 15:47