File Exchange

Iseven/Isodd

version 1.0 (1.65 KB) by

Simple helper files that return true/false based on whether inputs are even or odd, respectively

Updated

% iseven - Returns true if the input is an even whole number
% Syntax: tf = iseven(x)
% x - numeric (real) input of any number of dimensions and sizes
% tf - true for each element that is an even whole number
% Example
% tf = iseven([1,3,4]);
%

% isodd - Returns true if the input is an odd integer
% Syntax: tf = isodd(x)
% x - numeric (real) input of any number of dimensions and sizes
% tf - true for each element that is an odd integer
% Example
% tf = isodd([1,3,4]);
%

Jan Simon

Jan Simon (view profile)

There are some functions in the FEX already, which determine if a number is odd or even, see: http://www.mathworks.com/matlabcentral/fileexchange/?term=isodd
Some of them consider NaN, +/-Inf, integer types and numbers which cannot be represented exactly as 2^54-1 or 2^54.
There have been a lot of discussions already and I do not want to start another one. I do not think, that this submission adds anything new to the FEX. There is a documentation, the functions work as expected inside the *not* specified limitations. The error message in "isodd" claims, that it is the function "iseven".

MATLAB Release
MATLAB 7.13 (R2011b)