do cross check source label list with destination label list [usage] [idx_list] = vb_util_get_cross_checked_list(src_list, dst_list) [input] src_list : <required> source list of label : [N x 1] or [1 x N] dst_list : <required> destination list of label : [M x 1] or [1 x M] [output] idx_list : index list [N x 2] : [dst_idx, src_idx] (if N/A, src_idx is set '-1') [note] [history] 2007-04-13 (Sako) initial version Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [idx_list] = vb_util_get_cross_checked_list(src_list, dst_list) 0002 % do cross check source label list with destination label list 0003 % [usage] 0004 % [idx_list] = vb_util_get_cross_checked_list(src_list, dst_list) 0005 % [input] 0006 % src_list : <required> source list of label 0007 % : [N x 1] or [1 x N] 0008 % dst_list : <required> destination list of label 0009 % : [M x 1] or [1 x M] 0010 % [output] 0011 % idx_list : index list [N x 2] 0012 % : [dst_idx, src_idx] (if N/A, src_idx is set '-1') 0013 % [note] 0014 % 0015 % [history] 0016 % 2007-04-13 (Sako) initial version 0017 % 0018 % Copyright (C) 2011, ATR All Rights Reserved. 0019 % License : New BSD License(see VBMEG_LICENSE.txt) 0020 0021 % --- CHECK ARGUMENTS --- % 0022 if ~exist('src_list', 'var') src_list = []; end; 0023 if ~exist('dst_list', 'var') dst_list = []; end; 0024 [src_list, dst_list] = inner_check_arguments(src_list, dst_list); 0025 % both lists are arranged [1 x N] 0026 0027 % --- MAIN PROCEDURE --------------------------------------------------------- % 0028 % 0029 N_DATA = size(src_list, 2); % [1 x N] 0030 idx_list = zeros(N_DATA, 2); 0031 0032 for i_data = 1:N_DATA 0033 idx_list(i_data, 1) = i_data; 0034 idx_list(i_data, 2) = inner_search_label(dst_list, src_list{i_data}); 0035 end 0036 % 0037 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0038 0039 % --- INNER FUNCTIONS -------------------------------------------------------- % 0040 % 0041 % --- inner_check_arguments() 0042 % 0043 function [src_list, dst_list] = inner_check_arguments(src_list, dst_list) 0044 if isempty(src_list) 0045 error('src_list is a required parameter'); 0046 end 0047 0048 if isempty(dst_list) 0049 error('dst_list is a required parameter'); 0050 end 0051 0052 src_list = vb_util_arrange_list(src_list,1); 0053 dst_list = vb_util_arrange_list(dst_list,1); 0054 return; 0055 % 0056 % --- end of inner_check_arguments() 0057 0058 % --- inner_search_label() 0059 % 0060 function [app_idx] = inner_search_label(label_list, label) 0061 % <<prior conditions>> 0062 % Both label_list and label are not empty. 0063 % label_list is [1 x N] 0064 0065 N_A = -1; % not applicable 0066 list_len = size(label_list, 2); % [1 x N] 0067 0068 for i_d = 1:list_len 0069 if strcmp(label_list{i_d}, label) 0070 app_idx = i_d; 0071 return; 0072 end 0073 end 0074 0075 app_idx = N_A; 0076 return; 0077 % 0078 % --- end of inner_search_label() 0079 0080 % 0081 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0082 0083 %%% END OF FILE %%%