The NEAREST function is not designed for complex numbers and works only with real numbers. ROUND works well with complex numbers as it is designed for this purpose. If you do not wish to use ROUND, then the following function NEAREST1 may be helpful:
function y = nearest1(x)
if (isreal(x) ==0)
y = floor(x+0.5+0.5j);
else
y = floor(x+0.5);
end
Best Answer