File Exchange

image thumbnail


version (1.71 KB) by Marco Cococcioni
Converts a numeric vector into a cell vector of strings.


Updated 17 Jul 2008

View License

This function converts a numeric vector into a cell vector of strings. Each element of the cell contains the string conversion of the corresponding entry in the numeric vector, prefixed and postfixed by strings provided by the user. The format for numeric to string conversion can also be specified.
Useful for creating legend labels or tick labels.

Cite As

Marco Cococcioni (2020). NUM2LAB (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Marco Cococcioni

Thank you Jos! I have updated the submission using your suggestion!

Jos x@y.z

Better to use the oneliner:

% data
V = [1 2 3 4.5 6 pi] ;
prestr = 'Text before '
poststr = ' .. and after '
formstr = '%.2f' ;

% engine
C = cellstr(num2str(V(:),[prestr formstr poststr]))


Core function replaced with the more efficient version based on the use of cellstr and num2str (thanks to Jos).

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux