Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slpwcalc
Home > sltoolbox > core > slpwcalc.m

slpwcalc

PURPOSE ^

SLPWCALC Calculates a table pairwisely on two set of scalars

SYNOPSIS ^

function M = slpwcalc(v1, v2, op)

DESCRIPTION ^

SLPWCALC Calculates a table pairwisely on two set of scalars

 $ Syntax $
   - M = slpwcalc(v1, v2, op)

 $ Arguments $
   - v1:       The vector of the first set of numbers (length n1)     
   - v2:       The vector of the second set of numbers (length n2)
   - op:       The calculation type
   - M:        The calculated table (n1 x n2)

 $ Description $
   - M = slpwcalc(v1, v2, op) calculates theon the scalars in v1 and v2
     pairwisely to make the result table M. op is the string indicating
     the calculation type to take. Available op include:
       'add':      addition:       M(i, j) = v1(i) + v2(j)
       'mul':      multiplication: M(i, j) = v1(i) * v2(j)
       'absdiff':  absolute diff:  M(i, j) = abs(v1(i) - v2(j))
       'max':      maximum value:  M(i, j) = max(v1(i), v2(j))
       'min':      minimum value:  M(i, j) = min(v1(i), v2(j))

 $ Remarks $
   - It simply wraps the core mex: pwcalc_core

   - both v1 and v2 should be vectors
 
 $ History $
   - Created by Dahua Lin, on Sep 11st, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
  • raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
This function is called by:

SOURCE CODE ^

0001 function M = slpwcalc(v1, v2, op)
0002 %SLPWCALC Calculates a table pairwisely on two set of scalars
0003 %
0004 % $ Syntax $
0005 %   - M = slpwcalc(v1, v2, op)
0006 %
0007 % $ Arguments $
0008 %   - v1:       The vector of the first set of numbers (length n1)
0009 %   - v2:       The vector of the second set of numbers (length n2)
0010 %   - op:       The calculation type
0011 %   - M:        The calculated table (n1 x n2)
0012 %
0013 % $ Description $
0014 %   - M = slpwcalc(v1, v2, op) calculates theon the scalars in v1 and v2
0015 %     pairwisely to make the result table M. op is the string indicating
0016 %     the calculation type to take. Available op include:
0017 %       'add':      addition:       M(i, j) = v1(i) + v2(j)
0018 %       'mul':      multiplication: M(i, j) = v1(i) * v2(j)
0019 %       'absdiff':  absolute diff:  M(i, j) = abs(v1(i) - v2(j))
0020 %       'max':      maximum value:  M(i, j) = max(v1(i), v2(j))
0021 %       'min':      minimum value:  M(i, j) = min(v1(i), v2(j))
0022 %
0023 % $ Remarks $
0024 %   - It simply wraps the core mex: pwcalc_core
0025 %
0026 %   - both v1 and v2 should be vectors
0027 %
0028 % $ History $
0029 %   - Created by Dahua Lin, on Sep 11st, 2006
0030 %
0031 
0032 %% parse and verify input
0033 
0034 if nargin < 3
0035     raise_lackinput('slpwcalc', 3);
0036 end
0037 
0038 if ~isvector(v1) || ~isvector(v2)
0039     error('sltoolbox:invalidarg', 'both v1 and v2 should be vectors');
0040 end
0041 
0042 switch op
0043     case 'add'
0044         opcode = 1;
0045     case 'mul'
0046         opcode = 2;
0047     case 'absdiff'
0048         opcode = 3;
0049     case 'max'
0050         opcode = 4;
0051     case 'min'
0052         opcode = 5;
0053     otherwise
0054         error('sltoolbox:invalidarg', 'Invalid op type for pwcalc: %s', op);
0055 end
0056 
0057 %% main
0058 
0059 M = pwcalc_core(v1, v2, opcode);
0060         
0061 
0062 
0063 
0064 
0065 
0066

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com