1% Concatenate a cell array. 2% 3% x = cat_cell_array(c) 4% 5% Concatenate all arrays of the cell array c along the dimension length(c)+1 6 7 8function x = cat_cell_array(x) 9 10do_grid = 0; 11 12if iscell(x) 13 n = length(x); 14 15 if do_grid 16 all_vectors = 1; 17 18 for i=1:n 19 all_vectors = all_vectors & isvector(x{i}); 20 end 21 22 if all_vectors 23 [x{:}] = ndgrid(x{:}); 24 end 25 end 26 27 sz = size(x{1}); 28 for i=2:n 29 if ~isequal(sz,size(x{i})) 30 %sz 31 %size(x{i}) 32 error('all arguments in cell array should have the same size'); 33 end 34 end 35 36 x = cat(n+1,x{:}); 37 end 38end 39 40 41 42% Copyright (C) 2009 Alexander Barth <a.barth@ulg.ac.be> 43% 44% This program is free software; you can redistribute it and/or modify 45% it under the terms of the GNU General Public License as published by 46% the Free Software Foundation; either version 2 of the License, or 47% (at your option) any later version. 48% 49% This program is distributed in the hope that it will be useful, 50% but WITHOUT ANY WARRANTY; without even the implied warranty of 51% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 52% GNU General Public License for more details. 53% 54% You should have received a copy of the GNU General Public License 55% along with this program; If not, see <http://www.gnu.org/licenses/>. 56 57