arrange to [N x 1] or [1 x N] [usage] arranged_list = vb_util_arrange_list(list, mode) [input] list : array whose size must be [N x 1] or [1 x N] mode : arranging mode (0 or 1) [0] : 0 : arrange to [N x 1] : 1 : arrange to [1 x N] [output] arranged_list : list which has been arranged [note] [history] 2006-12-05 (Sako) initial version Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function arranged_list = vb_util_arrange_list(list, mode) 0002 % arrange to [N x 1] or [1 x N] 0003 % [usage] 0004 % arranged_list = vb_util_arrange_list(list, mode) 0005 % [input] 0006 % list : array whose size must be [N x 1] or [1 x N] 0007 % mode : arranging mode (0 or 1) [0] 0008 % : 0 : arrange to [N x 1] 0009 % : 1 : arrange to [1 x N] 0010 % [output] 0011 % arranged_list : list which has been arranged 0012 % [note] 0013 % 0014 % [history] 0015 % 2006-12-05 (Sako) initial version 0016 % 0017 % Copyright (C) 2011, ATR All Rights Reserved. 0018 % License : New BSD License(see VBMEG_LICENSE.txt) 0019 if ~exist('mode', 'var') || isempty(mode) 0020 mode = 0; 0021 end 0022 0023 nr = size(list,1); 0024 nc = size(list,2); 0025 0026 if nr ~= 1 && nc ~= 1 0027 error('invalid list size [%d x %d]', nr, nc); 0028 end 0029 0030 if mode == 0 % to [N x 1] 0031 if nr == 1 0032 arranged_list = list'; 0033 else 0034 arranged_list = list; 0035 end 0036 elseif mode == 1 % to [1 x N] 0037 if nr == 1 0038 arranged_list = list; 0039 else 0040 arranged_list = list'; 0041 end 0042 else 0043 error('undefined mode : %d', mode); 0044 end 0045 0046 %%% END OF FILE %%%