No BSD License  

Highlights from
num2cellstr

5.0

5.0 | 2 ratings Rate this file 3 Downloads (last 30 days) File Size: 2.35 KB File ID: #20639

num2cellstr

by Andrew Watson

 

09 Jul 2008 (Updated 10 Jul 2008)

num2CellStr converts numeric or logical array to a cell array of strings

| Watch this File

File Information
Description

num2CellStr - converts numeric or logical array to a cell array of strings

This was inspired by a recent FEX submission of the same name. However,
it should run about 100 times faster. It also runs ~12 times faster than
the one liner:

    cellA = reshape(cellstr(num2str(A(:))),size(A));

Syntax:

strCell = num2CellStr(x, format)

Input parameters:

      x - mandatory matrix of numeric values
      format - optional format specifier. If not specified one is
                  picked based on the data up to 5 decimal places

Output parameters:

      strCell - cell array of strings

Examples:

num2CellStr(rand(2),'%.2f')

ans =

    '0.06' '0.61'
    '0.13' '0.39'

See also:
num2cell, mat2cell, textscan, strread

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
16 Mar 2009 john

Extremely useful! Works just like I thought it would.

05 Aug 2009 Dirk Engel  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
structures Andrew Watson 22 Oct 2008 10:09:39
cell arrays Andrew Watson 22 Oct 2008 10:09:39
num2cellstr Andrew Watson 22 Oct 2008 10:09:39
cellstr Andrew Watson 22 Oct 2008 10:09:39
string Andrew Watson 22 Oct 2008 10:09:39
cell array Andrew Watson 22 Oct 2008 10:09:39

Contact us at files@mathworks.com