Home > functions > common > utility > vb_util_check_numerical_lists.m

vb_util_check_numerical_lists

PURPOSE ^

check two numerical lists whether target is included by base

SYNOPSIS ^

function [result,idx] = vb_util_check_numerical_lists(base, target)

DESCRIPTION ^

 check two numerical lists whether target is included by base
 [usage]
   [result,idx] = vb_util_check_numerical_lists(base, target)
 [input]
     base : <required> numerical list of baseline
          :  - [n x 1] or [1 x n]
   target : <required> numerical list that is checked
          :  - [n x 1] or [1 x n]
 [output]
   result : <<boolean>>
          :   true : base includes all the elements of target
          :  false : all the elements of target are not included in base
      idx : corresponding index of base
          : [Nidx x 1]
 [note]
   @see vb_util_arrange_list
   @see vb_util_check_string_lists
 [history]
   2007-06-06 (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 [result,idx] = vb_util_check_numerical_lists(base, target)
0002 % check two numerical lists whether target is included by base
0003 % [usage]
0004 %   [result,idx] = vb_util_check_numerical_lists(base, target)
0005 % [input]
0006 %     base : <required> numerical list of baseline
0007 %          :  - [n x 1] or [1 x n]
0008 %   target : <required> numerical list that is checked
0009 %          :  - [n x 1] or [1 x n]
0010 % [output]
0011 %   result : <<boolean>>
0012 %          :   true : base includes all the elements of target
0013 %          :  false : all the elements of target are not included in base
0014 %      idx : corresponding index of base
0015 %          : [Nidx x 1]
0016 % [note]
0017 %   @see vb_util_arrange_list
0018 %   @see vb_util_check_string_lists
0019 % [history]
0020 %   2007-06-06 (Sako) initial version
0021 %
0022 % Copyright (C) 2011, ATR All Rights Reserved.
0023 % License : New BSD License(see VBMEG_LICENSE.txt)
0024 
0025 % --- CHECK ARGUMENTS --- %
0026 if ~exist('base', 'var'), base = []; end
0027 if ~exist('target', 'var'), target = []; end
0028 [base, target] = inner_check_arguments(base,target);
0029 
0030 % --- MAIN PROCEDURE --------------------------------------------------------- %
0031 %
0032 idx = [];
0033 result = true;
0034 
0035 for i = 1:size(target,1)
0036   tmp_idx = find(base == target(i));
0037   if isempty(tmp_idx)
0038     result = false;
0039 %     warning('''%d'' is not included in base_list', target(i));
0040   else
0041     idx = [idx;tmp_idx];
0042   end
0043 end
0044 return;
0045 
0046 % --- INNER FUNCTIONS -------------------------------------------------------- %
0047 %
0048 % --- inner_check_arguments()
0049 %
0050 function [base, target] = inner_check_arguments(base, target)
0051 func_ = mfilename;
0052 
0053 if isempty(base)
0054   error('(%s)base_list is a required parameter', func_);
0055 end
0056 
0057 if isempty(target)
0058   error('(%s)target_list is a required parameter', func_);
0059 end
0060 
0061 % arrange to [N x 1]
0062 base   = vb_util_arrange_list(base);
0063 target = vb_util_arrange_list(target);
0064 return;
0065 %
0066 % --- end of inner_check_arguments()
0067 %
0068 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0069 
0070 %%% END OF FILE %%%

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005