Display message WITH new line. This function shows a message on the MATLAB console. The message is automatically suppressed according to vbmeg_inst.verbose_level. [syntax] vb_disp(message,verbose_level_min) [input] message : <<string>> Message be shown. verbose_level_min: <optional> <<int or string>> Verbose level of this message. --- verbose level string (verbose_level_min) 'NONE' (=0) Suppressing all messages 'EMERGENCY' (=1) 'WARNING' (=2) 'NOTICE' (=3) VBMEG default value 'INFO' (=5) 'DEBUG' (=10) Displaying all messages --- [example] >> vb_disp('message\n'); % same with below >> vb_disp('message\n','NOTICE'); % default=NOTICE >> vb_disp('message\n',3); % 3 is NOTICE exmaple of message suppression >> vb_set_verbose('WARNING'); % making verbose level low >> vb_disp('message\n'); % same with the 1st line but none is shown [history] 2008-12-02 Taku Yoshioka 2011-06-20 taku-y [enhancement] String input argument supported. 2011-06-28 rhayashi message is shown by using disp() function. [see also] vb_set_verbose, vb_get_verbose, vb_disp_nonl Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function vb_disp(message,verbose_level_min) 0002 % Display message WITH new line. 0003 % 0004 % This function shows a message on the MATLAB console. The message is 0005 % automatically suppressed according to vbmeg_inst.verbose_level. 0006 % 0007 % [syntax] 0008 % vb_disp(message,verbose_level_min) 0009 % 0010 % [input] 0011 % message : <<string>> Message be shown. 0012 % verbose_level_min: <optional> <<int or string>> Verbose level of this 0013 % message. 0014 % --- verbose level string (verbose_level_min) 0015 % 'NONE' (=0) Suppressing all messages 0016 % 'EMERGENCY' (=1) 0017 % 'WARNING' (=2) 0018 % 'NOTICE' (=3) VBMEG default value 0019 % 'INFO' (=5) 0020 % 'DEBUG' (=10) Displaying all messages 0021 % --- 0022 % 0023 % [example] 0024 % >> vb_disp('message\n'); % same with below 0025 % >> vb_disp('message\n','NOTICE'); % default=NOTICE 0026 % >> vb_disp('message\n',3); % 3 is NOTICE 0027 % 0028 % exmaple of message suppression 0029 % >> vb_set_verbose('WARNING'); % making verbose level low 0030 % >> vb_disp('message\n'); % same with the 1st line but none is shown 0031 % 0032 % [history] 0033 % 2008-12-02 Taku Yoshioka 0034 % 2011-06-20 taku-y 0035 % [enhancement] String input argument supported. 0036 % 2011-06-28 rhayashi message is shown by using disp() function. 0037 % 0038 % [see also] 0039 % vb_set_verbose, vb_get_verbose, vb_disp_nonl 0040 % 0041 % Copyright (C) 2011, ATR All Rights Reserved. 0042 % License : New BSD License(see VBMEG_LICENSE.txt) 0043 0044 global vbmeg_inst; 0045 const = vb_define_verbose; 0046 0047 if nargin<2 || isempty(verbose_level_min), 0048 verbose_level_min = const.VERBOSE_LEVEL_NOTICE; 0049 end 0050 0051 if ischar(verbose_level_min) 0052 switch verbose_level_min 0053 case 'NONE' 0054 verbose_level_min = 0; 0055 case 'EMERGENCY' 0056 verbose_level_min = 1; 0057 case 'WARNING' 0058 verbose_level_min = 2; 0059 case 'NOTICE' 0060 verbose_level_min = 3; 0061 case 'INFO' 0062 verbose_level_min = 5; 0063 case 'DEBUG' 0064 verbose_level_min = 10; 0065 otherwise 0066 fprintf('Invalid verbose string: %s\n',verbose_level_min); 0067 end 0068 end 0069 0070 if isempty(vbmeg_inst) || ~isfield(vbmeg_inst,'verbose_level') 0071 verbose_level = const.VERBOSE_LEVEL_NOTICE; 0072 else 0073 verbose_level = vbmeg_inst.verbose_level; 0074 end 0075 0076 if verbose_level>=verbose_level_min 0077 disp([const.verbose_level_str{verbose_level_min+1} message]); 0078 end