return matching index numbers on base label list [usage] match_idx = vb_util_get_matching_label_index(base_labels, target_labels) [input] base_labels : <required> base label list - cell array {N x 1} target_labels : <required> target label list - cell array {N x 1} [output] match_idx : index numbers on base_labels (N x 1) [note] [see also] vb_util_get_index [history] 2011-07-28 (Sako) initial version Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [match_idx] = ... 0002 vb_util_get_matching_label_index(base_labels, target_labels) 0003 % return matching index numbers on base label list 0004 % [usage] 0005 % match_idx = vb_util_get_matching_label_index(base_labels, target_labels) 0006 % [input] 0007 % base_labels : <required> base label list - cell array {N x 1} 0008 % target_labels : <required> target label list - cell array {N x 1} 0009 % [output] 0010 % match_idx : index numbers on base_labels (N x 1) 0011 % [note] 0012 % 0013 % [see also] 0014 % vb_util_get_index 0015 % 0016 % [history] 0017 % 2011-07-28 (Sako) initial version 0018 % 0019 % Copyright (C) 2011, ATR All Rights Reserved. 0020 % License : New BSD License(see VBMEG_LICENSE.txt) 0021 0022 % --- CHECK ARGUMENTS --- % 0023 if ~exist('base_labels', 'var'), base_labels = []; end 0024 if ~exist('target_labels', 'var'), target_labels = []; end 0025 [base_labels, target_labels] = ... 0026 inner_check_arguments(base_labels, target_labels); 0027 0028 % --- MAIN PROCEDURE --------------------------------------------------------- % 0029 % 0030 match_idx = []; 0031 n_target = size(target_labels, 1); 0032 0033 for i_target = 1:n_target 0034 cur_idx = find(strcmp(base_labels, target_labels{i_target}) == 1); 0035 0036 if isempty(cur_idx), continue; end 0037 0038 match_idx = [match_idx;cur_idx]; 0039 end 0040 return; 0041 % 0042 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0043 0044 0045 % --- INNER FUNCTIONS -------------------------------------------------------- % 0046 % 0047 % --- inner_check_arguments() 0048 % 0049 function [base_labels, target_labels] = ... 0050 inner_check_arguments(base_labels, target_labels) 0051 0052 func_ = mfilename; 0053 0054 if isempty(base_labels) 0055 error('(%s)base_labels is a required parameter', func_); 0056 end 0057 0058 if isempty(target_labels) 0059 error('(%s)target_labels is a required parameter', func_); 0060 end 0061 0062 if ~iscell(base_labels) 0063 base_labels = {base_labels}; 0064 end 0065 0066 if ~iscell(target_labels) 0067 target_labels = {target_labels}; 0068 end 0069 0070 % re-arrange arrays 0071 base_labels = vb_util_arrange_list(base_labels); 0072 target_labels = vb_util_arrange_list(target_labels); 0073 return; 0074 % 0075 % --- end of inner_check_arguments() 0076 0077 % --- END OF FILE --- %