# HG changeset patch # User Jaroslav Hajek # Date 1269411224 -3600 # Node ID 03d0dea2309d797615cac7c5b1d450bb37a20028 # Parent 146e615b667496161f7a94eb3a89f5f54acf5de2 support cells of cells in cell2mat diff -r 146e615b6674 -r 03d0dea2309d scripts/ChangeLog --- a/scripts/ChangeLog Tue Mar 23 17:48:54 2010 -0400 +++ b/scripts/ChangeLog Wed Mar 24 07:13:44 2010 +0100 @@ -1,3 +1,7 @@ +2010-03-24 Jaroslav Hajek + + * general/cell2mat.m: Support cells of cells. + 2010-03-23 John W. Eaton * plot/refreshdata.m: Don't use cell2mat on cell array of cell arrays. diff -r 146e615b6674 -r 03d0dea2309d scripts/general/cell2mat.m --- a/scripts/general/cell2mat.m Tue Mar 23 17:48:54 2010 -0400 +++ b/scripts/general/cell2mat.m Wed Mar 24 07:13:44 2010 +0100 @@ -20,8 +20,8 @@ ## @deftypefn {Function File} {@var{m} =} cell2mat (@var{c}) ## Convert the cell array @var{c} into a matrix by concatenating all ## elements of @var{c} into a hyperrectangle. Elements of @var{c} must -## be numeric, logical or char, and @code{cat} must be able to -## concatenate them together. +## be numeric, logical or char matrices, or cell arrays, and @code{cat} +## must be able to concatenate them together. ## @seealso{mat2cell, num2cell} ## @end deftypefn @@ -41,9 +41,10 @@ valid = cellfun (@isnumeric, c); valid |= cellfun (@islogical, c); valid |= cellfun (@ischar, c); + validc = cellfun (@iscell, c); - if (! all (valid)) - error ("cell2mat: elements must be numeric, char or logical"); + if (! all (valid(:)) && ! all (validc(:))) + error ("cell2mat: wrong type elements or mixed cells and matrices"); endif if (nb == 0)