Home > vbmeg > functions > common > utility > vb_util_get_labels_to_read.m

vb_util_get_labels_to_read

PURPOSE ^

return labels to read

SYNOPSIS ^

function [labels, idx] =vb_util_get_labels_to_read(base_list, target_list, to_read_swt)

DESCRIPTION ^

 return labels to read
 (mainly be used in order to decide channel list to read)
 [usage]
   [labels, idx] = ...
      vb_util_get_labels_to_read(base_list, target_list, to_read_swt)
 [input]
     base_list : <required>
               :   base list of labels that must include "target_list"
   target_list : <optional>
               :   target list whose purpose is decided by 'to_read_swt' [[]]
   to_read_swt : <optional> <<boolean>> switch whether to read or not
               : [true]) target_list means to be included
               :  false) target_list means not to be included
 [output]
        labels : label list to read [N x 1]
           idx : index of base_list
 [note]
   <case that empty "labels" is returned>
     - base_list is not given or is empty
     - target_list is not given or is empty and to_read_swt is true
     - target_list is not included in base_list
     -- would return with warning message
   @see vb_util_is_included_list
   @see vb_util_omit_list
 [history]
   2006-12-18 (Sako) initial version
   2008-02-27 (Sako) thoroughly revised 

 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 [labels, idx] = ...
0002   vb_util_get_labels_to_read(base_list, target_list, to_read_swt)
0003 % return labels to read
0004 % (mainly be used in order to decide channel list to read)
0005 % [usage]
0006 %   [labels, idx] = ...
0007 %      vb_util_get_labels_to_read(base_list, target_list, to_read_swt)
0008 % [input]
0009 %     base_list : <required>
0010 %               :   base list of labels that must include "target_list"
0011 %   target_list : <optional>
0012 %               :   target list whose purpose is decided by 'to_read_swt' [[]]
0013 %   to_read_swt : <optional> <<boolean>> switch whether to read or not
0014 %               : [true]) target_list means to be included
0015 %               :  false) target_list means not to be included
0016 % [output]
0017 %        labels : label list to read [N x 1]
0018 %           idx : index of base_list
0019 % [note]
0020 %   <case that empty "labels" is returned>
0021 %     - base_list is not given or is empty
0022 %     - target_list is not given or is empty and to_read_swt is true
0023 %     - target_list is not included in base_list
0024 %     -- would return with warning message
0025 %   @see vb_util_is_included_list
0026 %   @see vb_util_omit_list
0027 % [history]
0028 %   2006-12-18 (Sako) initial version
0029 %   2008-02-27 (Sako) thoroughly revised
0030 %
0031 % Copyright (C) 2011, ATR All Rights Reserved.
0032 % License : New BSD License(see VBMEG_LICENSE.txt)
0033 
0034 % --- CHECK ARGUMENTS --- %
0035 if ~exist('base_list', 'var'), base_list = []; end
0036 if ~exist('target_list', 'var'), target_list = []; end
0037 if ~exist('to_read_swt', 'var'), to_read_swt = []; end
0038 
0039 [base_list, to_read_swt, target_list, empty_flg] = ...
0040   inner_check_arguments(base_list, target_list, to_read_swt);
0041 
0042 % --- MAIN PROCEDURE --------------------------------------------------------- %
0043 %
0044 labels = [];
0045 idx = [];
0046 
0047 if empty_flg, return; end;
0048 
0049 if to_read_swt == false
0050   [labels, idx] = vb_util_omit_list(base_list, target_list);
0051       
0052 else
0053   [result, idx] = vb_util_is_included_list(base_list, target_list);
0054   if ~isempty(idx)
0055     labels = vb_util_arrange_list(base_list(idx));
0056   end
0057 end
0058 return;
0059 %
0060 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0061 
0062 
0063 % --- INNER FUNCTIONS -------------------------------------------------------- %
0064 %
0065 % --- inner_check_arguments()
0066 %
0067 function [base_list, to_read_swt, target_list, empty_flg] = ...
0068   inner_check_arguments(base_list, target_list, to_read_swt)
0069 func_ = mfilename;
0070 empty_flg = true;
0071 
0072 if isempty(base_list)
0073   fprintf('(%s)base_list is empty\n', func_);
0074   return;
0075 end
0076 
0077 if isempty(to_read_swt)
0078   to_read_swt = true;
0079 end
0080 
0081 % ----- target list
0082 if isempty(target_list)
0083   if to_read_swt == true
0084     fprintf('(%s)Though target_list means ''to read'', it is empty\n', ...
0085       func_);
0086     return;
0087   else
0088     % target_list is empty and it means not to be included
0089     target_list = base_list;
0090     to_read_swt = true;
0091   end
0092 end
0093 empty_flg = false;
0094 return;
0095 %
0096 % --- end of inner_check_arguments()
0097 
0098 %%% END OF FILE %%%

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