Home > vbmeg > functions > leadfield > head > vb_util_convert_rmethod2calcmode.m

vb_util_convert_rmethod2calcmode

PURPOSE ^

convert Rmethod (string) to calc_mode (numeric)

SYNOPSIS ^

function [calcmode] = vb_util_convert_rmethod2calcmode(rmethod)

DESCRIPTION ^

 convert Rmethod (string) to calc_mode (numeric)
 [usage]
   [calcmode] = vb_util_convert_rmethod2calcmode(rmethod)
 [input]
   rmethod : <required> Rmethod string as follow
           :  'MEAN' or 'MIN' or 'MAX'
 [output]
   calcmode : calculation mode
            :  'MEAN' --> 1
            :  'MIN' ---> 2
            :  'MAX' ---> 3
            :  'USER' --> 4
            :  unknown -> 0
 [note]
   case-insensitive
 [history]
   2007-06-15 (Sako) initial version

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [calcmode] = vb_util_convert_rmethod2calcmode(rmethod)
0002 % convert Rmethod (string) to calc_mode (numeric)
0003 % [usage]
0004 %   [calcmode] = vb_util_convert_rmethod2calcmode(rmethod)
0005 % [input]
0006 %   rmethod : <required> Rmethod string as follow
0007 %           :  'MEAN' or 'MIN' or 'MAX'
0008 % [output]
0009 %   calcmode : calculation mode
0010 %            :  'MEAN' --> 1
0011 %            :  'MIN' ---> 2
0012 %            :  'MAX' ---> 3
0013 %            :  'USER' --> 4
0014 %            :  unknown -> 0
0015 % [note]
0016 %   case-insensitive
0017 % [history]
0018 %   2007-06-15 (Sako) initial version
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 % --- CHECK ARGUMENTS --- %
0024 if ~exist('rmethod', 'var') rmethod = []; end
0025 [rmethod] = inner_check_arguments(rmethod);
0026 
0027 % --- MAIN PROCEDURE --------------------------------------------------------- %
0028 %
0029 % constants
0030 func_ = 'vb_util_convert_rmethod2calcmode';
0031 
0032 METHOD(1).name = 'MEAN'; METHOD(1).code = 1;
0033 METHOD(2).name = 'MIN';  METHOD(2).code = 2;
0034 METHOD(3).name = 'MAX';  METHOD(3).code = 3;
0035 METHOD(4).name = 'USER'; METHOD(4).code = 4;
0036 
0037 % unknown method
0038 UNKNOWN_METHOD = 0;
0039 
0040 for im = 1:size(METHOD,2)
0041   if strcmp(rmethod, METHOD(im).name)
0042     calcmode = METHOD(im).code;
0043     return;
0044   end
0045 end
0046 calcmode = UNKNOWN_METHOD;
0047 %
0048 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0049 
0050 
0051 % --- INNER FUNCTIONS -------------------------------------------------------- %
0052 %
0053 % --- inner_check_arguments()
0054 %
0055 function [rmethod] = inner_check_arguments(rmethod)
0056 func_ = 'vb_util_convert_rmethod2calcmode';
0057 if isempty(rmethod)
0058   error('(%s)rmethod is a required parameter', func_);
0059 end
0060 
0061 % case-insensitive
0062 rmethod = upper(rmethod);
0063 return;
0064 %
0065 % --- end of inner_check_arguments()
0066 %
0067 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0068 
0069 %%% END OF FILE %%%

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005