Home > sgwt_toolbox > utils > argselectCheck.m

argselectCheck

PURPOSE ^

argselectCheck : Check if control parameters are valid

SYNOPSIS ^

function argselectCheck(control_params,varargin_in)

DESCRIPTION ^

 argselectCheck : Check if control parameters are valid 

  function argselectCheck(control_params,varargin_in)

  Inputs: 
  control_params and varargin_in are both cell arrays
  that are lists of pairs 'name1',value1,'name2',value2,...

  This function checks that every name in varargin_in is one of the names
  in control_params. It will generate an error if not, otherwise it will 
  do nothing

  This is used at beginning of function to simulate keyword argument
  passing. Typical usage is

  argselectAssign(control_params);
  argselectCheck(control_params,varargin);
  argselectAssign(varargin);

  where control_params is a cell list of variable,value pairs containing
  the default parameter values.

 See also argselectAssign

 Author : David K. Hammond, EPFL LTS2
 Date : December, 2007
 Project : common utilities

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % argselectCheck : Check if control parameters are valid
0002 %
0003 %  function argselectCheck(control_params,varargin_in)
0004 %
0005 %  Inputs:
0006 %  control_params and varargin_in are both cell arrays
0007 %  that are lists of pairs 'name1',value1,'name2',value2,...
0008 %
0009 %  This function checks that every name in varargin_in is one of the names
0010 %  in control_params. It will generate an error if not, otherwise it will
0011 %  do nothing
0012 %
0013 %  This is used at beginning of function to simulate keyword argument
0014 %  passing. Typical usage is
0015 %
0016 %  argselectAssign(control_params);
0017 %  argselectCheck(control_params,varargin);
0018 %  argselectAssign(varargin);
0019 %
0020 %  where control_params is a cell list of variable,value pairs containing
0021 %  the default parameter values.
0022 %
0023 % See also argselectAssign
0024 %
0025 % Author : David K. Hammond, EPFL LTS2
0026 % Date : December, 2007
0027 % Project : common utilities
0028 
0029 % This file is part of the SGWT toolbox (Spectral Graph Wavelet Transform toolbox)
0030 % Copyright (C) 2010, David K. Hammond.
0031 %
0032 % The SGWT toolbox is free software: you can redistribute it and/or modify
0033 % it under the terms of the GNU General Public License as published by
0034 % the Free Software Foundation, either version 3 of the License, or
0035 % (at your option) any later version.
0036 %
0037 % The SGWT toolbox is distributed in the hope that it will be useful,
0038 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0039 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0040 % GNU General Public License for more details.
0041 %
0042 % You should have received a copy of the GNU General Public License
0043 % along with the SGWT toolbox.  If not, see <http://www.gnu.org/licenses/>.
0044 
0045 function argselectCheck(control_params,varargin_in)
0046 [param_names{1:(length(control_params)/2)}]=control_params{1:2:end};
0047 % check that passed in control parameters are valid
0048 for j=1:2:length(varargin_in)
0049   if(isempty(strmatch(varargin_in{j},param_names)))
0050     error(['Invalid control parameter : ',varargin_in{j},...
0051            ' Valid options are',sprintf('\n'),...
0052           sprintf('%s \n',param_names{:})]);
0053   end
0054 end

Generated on Tue 04-May-2010 16:00:20 by m2html © 2003