File Exchange

image thumbnail

num2cellstr

version 1.0 (2.35 KB) by

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

0 Downloads

Updated

No License

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

Comments and Ratings (5)

noknowledge

works!

Great! Just what I need. Thank you!

Haruki

Haruki (view profile)

useful

Dirk Engel

john

john (view profile)

Extremely useful! Works just like I thought it would.

MATLAB Release
MATLAB 7.5 (R2007b)

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

» Watch video