Mercurial > hg > octave-terminal
changeset 10441:03d0dea2309d
support cells of cells in cell2mat
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 24 Mar 2010 07:13:44 +0100 |
parents | 146e615b6674 |
children | 3011d1765a6e |
files | scripts/ChangeLog scripts/general/cell2mat.m |
diffstat | 2 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-03-24 Jaroslav Hajek <highegg@gmail.com> + + * general/cell2mat.m: Support cells of cells. + 2010-03-23 John W. Eaton <jwe@octave.org> * plot/refreshdata.m: Don't use cell2mat on cell array of cell arrays.
--- a/scripts/general/cell2mat.m +++ b/scripts/general/cell2mat.m @@ -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)