Home > atmlab > handy > rqre_element_math.m

rqre_element_math

PURPOSE ^

RQRE_ELEMENT_MATH Checks that element-by-element math can be used

SYNOPSIS ^

function rqre_element_math( a, b )

DESCRIPTION ^

 RQRE_ELEMENT_MATH   Checks that element-by-element math can be used

    Checks that *a* and *b* are both numeric, and have the same size or one
    of them is a scalar. That is, that the variables can be part of an
    expression where element-by-element math is applied (e.g. using .*).

    Issues an error if criterion not fulfilled.

 FORMAT   rqre_element_math( a, b )
        
 IN    a   A variable
       b   A second variable

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

rqre_element_math.m

SOURCE CODE ^

0001 % RQRE_ELEMENT_MATH   Checks that element-by-element math can be used
0002 %
0003 %    Checks that *a* and *b* are both numeric, and have the same size or one
0004 %    of them is a scalar. That is, that the variables can be part of an
0005 %    expression where element-by-element math is applied (e.g. using .*).
0006 %
0007 %    Issues an error if criterion not fulfilled.
0008 %
0009 % FORMAT   rqre_element_math( a, b )
0010 %
0011 % IN    a   A variable
0012 %       b   A second variable
0013 
0014 % 2010-01-04   Created by Patrick Eriksson.
0015 
0016 function rqre_element_math( a, b )
0017 
0018 rqre_datatype( a, @isnumeric, inputname(1) );
0019 rqre_datatype( b, @isnumeric, inputname(2) );
0020   
0021 if ~( isscalar(a)  ||  isscalar(b)  ||  all( size(a) == size(b) ) )
0022   error( ['The variables *%s* and *%s* must have the same size, or one has '...
0023                              'to be a scalar.' ], inputname(1), inputname(2) );
0024 end

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