Home > atmlab > math > iseven.m

iseven

PURPOSE ^

ISEVEN True for even integers.

SYNOPSIS ^

function bool = iseven(n)

DESCRIPTION ^

 ISEVEN   True for even integers.

    Determines if all the elements of an array are even integers. 
    
    Note that this function differs from *isinteger*, which is a type 
    test. Here also double numbers are accapted, as long as they are
    even integers.

 FORMAT   bool = iseven(n)
        
 OUT   bool   true if even integer, else false.
 IN    n      A variable of any valid numeric data type.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

iseven.m

SOURCE CODE ^

0001 % ISEVEN   True for even integers.
0002 %
0003 %    Determines if all the elements of an array are even integers.
0004 %
0005 %    Note that this function differs from *isinteger*, which is a type
0006 %    test. Here also double numbers are accapted, as long as they are
0007 %    even integers.
0008 %
0009 % FORMAT   bool = iseven(n)
0010 %
0011 % OUT   bool   true if even integer, else false.
0012 % IN    n      A variable of any valid numeric data type.
0013 
0014 % 2002-12-10  Created by Patrick Eriksson.
0015 
0016 
0017 function bool = iseven(n)
0018 
0019 bool = false;
0020 
0021 if isempty(n) | ~isnumeric(n), return, end
0022 
0023 if any( rem(n(:),2) == 1 ), return, end
0024 
0025 bool = true;

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005