Code covered by the BSD License  

Highlights from
Iseven/Isodd

3.0

3.0 | 1 rating Rate this file 10 Downloads (last 30 days) File Size: 1.65 KB File ID: #35105

Iseven/Isodd

by

 

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

| Watch this File

File Information
Description

  % 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]);
  %
  % See also: isodd

% 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]);
%
% See also: iseven

MATLAB release MATLAB 7.13 (R2011b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
16 Feb 2012 Jan Simon

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".

Contact us