The function must have been updated after the earlier reviews were written. This function is not working. I'm not sure why it would work. I just get a bunch of NaN's which is what I would expect after reading the code. The code returns NaN if the input cell is non-numeric. Since the input is a cell, it always returns NaN
1
23 Apr 2008
cell2num
Used to convert 2 dimensional cell array of single numbers to a matrix.
Phillip Feldman
Very handy. This really should be part of the Matlab base.
4
21 Nov 2007
cell2num
Used to convert 2 dimensional cell array of single numbers to a matrix.
Mohammad Reza Jahanbin
slightly more compact version of the same thing which work for n-d arrays
cell2num = @(x) reshape(cat(1,x{:}), size(x));
/m
Comment only
24 Aug 2007
cell2num
Used to convert 2 dimensional cell array of single numbers to a matrix.
C Schwalm
I should add that I stumbled upon this looking for something else and that, to fully sastisfy my need to get at cell arrays of cell arrays with numeric values, I added
elseif isnumeric(str2num(char(inputcell{r,c})));
outputmat(r,c)=str2num(char(inputcell{r,c}));
to your if-then construct. Again, I'd love for this to be built-in or vectorized and welcome anything that barks up this tree like your submission.
Comment only