return list exclusive of idx from body [usage] [mask_list, mask_idx, omit_list, omit_idx] = vb_util_clean_list(body, idx) [input] body : <required> baseline list [N x1] or [1x N] idx : <required> index you want to clean from body [N x1] or [1x N] [output] mask_list : list in which the 'idx' elements are cleaned [Nx1] mask_idx : indices of body which are except for idx omit_list : list to be omitted omit_idx : index list to be omitted [note] [history] 2008-02-27 (Sako) initial version 2009-08-10 (Sako) added return values (omit_list and omit_idx) Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [mask_list, mask_idx, omit_list, omit_idx] = vb_util_clean_list(body, idx) 0002 % return list exclusive of idx from body 0003 % [usage] 0004 % [mask_list, mask_idx, omit_list, omit_idx] = vb_util_clean_list(body, idx) 0005 % [input] 0006 % body : <required> baseline list [N x1] or [1x N] 0007 % idx : <required> index you want to clean from body [N x1] or [1x N] 0008 % [output] 0009 % mask_list : list in which the 'idx' elements are cleaned [Nx1] 0010 % mask_idx : indices of body which are except for idx 0011 % omit_list : list to be omitted 0012 % omit_idx : index list to be omitted 0013 % [note] 0014 % 0015 % [history] 0016 % 2008-02-27 (Sako) initial version 0017 % 2009-08-10 (Sako) added return values (omit_list and omit_idx) 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('body', 'var'), body = []; end 0024 if ~exist('idx', 'var'), idx = []; end 0025 [body, idx] = inner_check_arguments(body, idx); 0026 0027 % --- MAIN PROCEDURE --------------------------------------------------------- % 0028 % 0029 body_len = length(body); 0030 0031 % ----- get mask list 0032 mask_idx = []; 0033 omit_idx = []; 0034 0035 for i_body = 1:body_len 0036 if ~any(i_body == idx) 0037 mask_idx = [mask_idx; i_body]; 0038 else 0039 omit_idx = [omit_idx; i_body]; 0040 end 0041 end 0042 mask_list = body(mask_idx); 0043 omit_list = body(omit_idx); 0044 return 0045 % 0046 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0047 0048 % --- INNER FUNCTIONS -------------------------------------------------------- % 0049 % 0050 % --- inner_check_arguments() 0051 % 0052 function [body, idx] = inner_check_arguments(body, idx) 0053 func_ = mfilename; 0054 if isempty(body) 0055 error('(%s)body is a required parameter', func_); 0056 end 0057 0058 if isempty(idx) 0059 error('(%s)idx is a required parameter', func_); 0060 end 0061 0062 if length(body) < length(idx) 0063 error('(%s)body(L=%d) and idx(L=%d) are wrong', ... 0064 func_, length(body), length(idx)); 0065 end 0066 0067 % ----- arrange to [N x1] 0068 body = vb_util_arrange_list(body); 0069 idx = vb_util_arrange_list(idx); 0070 return; 0071 % 0072 % --- end of inner_check_arguments() 0073 % 0074 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0075 0076 %%% END OF FILE %%%