checknumericargs

PURPOSE ^

Helper utility for checking numeric vector arguments.

SYNOPSIS ^

function [x,er] = checknumericargs( x, siz, integerflag, signflag )

DESCRIPTION ^

 Helper utility for checking numeric vector arguments.

 Runs a number of tests on the numeric array x.  Tests to see if x has all integer
 values, all positive values, and so on, depending on the values for integerflag and
 signflag. Also tests to see if the size of x matches siz (unless siz==[]).  If x is a
 scalar, x is converted to a array simply by creating a matrix of size siz with x in each
 entry.  This is why the function returns x.  siz=M is equivalent to siz=[M M]. 

 If x does not satisfy some criteria, an error message is returned in er. If x satisfied
 all the criteria er=''.  Note that error('') has no effect, so can always use: "[x,er] =
 checknumericargs( x, ... ); error(er);", which will throw an error only if something was
 wrong with x.

 INPUTS
   x           - numeric array
   siz         - [if []]: does not test size of x
               - [if not []]: intended size for x
   integerflag - [if -1]: no need for integer x
                 [if  0]: error if non integer x
                 [if  1]: error if non odd integers
                 [if  2]: error if non even integers
   signflag    - [if -2]: entires of x must be strictly negative
                 [if -1]: entires of x must be negative
                 [if  0]: no contstraints on sign of entries in x
                 [if  1]: entires of x must be positive
                 [if  2]: entires of x must be strictly positive

 OUTPUTS
   x   - if x was a scalar it may have been replicated into a matrix 
   er  - contains error msg if anything was wrong with x

 EXAMPLE
   a=1;  [a,er] = checknumericargs( a, [1 3], 2, 0 ); a, error(er)

 DATESTAMP
   29-Sep-2005  2:00pm

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Wed 03-May-2006 23:48:50 by m2html © 2003