No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

2.7 | 6 ratings Rate this file 21 Downloads (last 30 days) File Size: 756 Bytes File ID: #15306 Version: 1.0



Darren (view profile)


14 Jun 2007 (Updated )

Used to convert 2 dimensional cell array of single numbers to a matrix.

| Watch this File

File Information

Function to convert an all numeric cell array to a double precision array
Output matrix will have the same dimensions as the input cell array
Non-numeric cell contest will become NaN outputs in outputmat
This function only works for 1-2 dimensional cell arrays of single numbers


This file inspired Rosin Rammler Diagram Plotting Tool and Cell2 Float.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Should work on all platforms
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
24 Oct 2015 Yuriy Monko

13 Sep 2011 Lube F

Lube F (view profile)

Same here. Function is now pointless.

22 Sep 2009 Kieran DSouza

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

23 Apr 2008 Phillip Feldman

Very handy. This really should be part of the Matlab base.

21 Nov 2007 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));


Comment only
24 Aug 2007 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})));

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
24 Aug 2007 C Schwalm

Yes, this is a wonderful thing. I would prefer to see this functionality be integrated into CELL2MAT. But it is not. I often have to extract numeric contents from a cell array of cell arrays (particularly when using regexpi). This is handy.

08 Aug 2007 Darren Brown

This function, although less powerful, is more tolerant than cell2mat because it can be used to extract numeric values from a cell array of mixed data types. Cell arrays are typically used to store strings along with numeric data. This function can retrieve just the numeric data.

Comment only
15 Jun 2007 John D'Errico

What purpose does this serve given the existence of cell2mat already in matlab? Also, this is limited to 1 or 2-d arrays, whereas cell2mat is not.

Finally, there is no error checking. You might argue that this (doubly looped) code checks for whether elements of the cell array are numeric or not, inserting NaNs there. But it still fails when the cell array elements are not scalar.

Contact us