Home > atmlab > math > isodd.m

isodd

PURPOSE ^

ISODD True for odd integers.

SYNOPSIS ^

function bool = isodd(n)

DESCRIPTION ^

 ISODD   True for odd integers.

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

 FORMAT   bool = iseven(n)
        
 OUT   bool   true if odd 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 ^

isodd.m

SOURCE CODE ^

0001 % ISODD   True for odd integers.
0002 %
0003 %    Determines if all the elements of an array are odd 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 %    odd integers.
0008 %
0009 % FORMAT   bool = iseven(n)
0010 %
0011 % OUT   bool   true if odd 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 = isodd(n)
0018 
0019 bool = false;
0020 
0021 if isempty(n) | ~isnumeric(n), return, end
0022 
0023 if any( rem(n(:),2) == 0 ), return, end
0024 
0025 bool = true;

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