MATLAB: Round to nearest odd integer

matlab function

Does MATLAB have a function to round numbers to the nearest odd integer?

Best Answer

I don't think so, but you could make your own:
function S = round_odd(S)
% round to nearest odd integer.
idx = mod(S,2)<1;
S = floor(S);
S(idx) = S(idx)+1;