How can I convert a numerical matrix into a cell array of strings in MATLAB?
73 views (last 30 days)
Show older comments
I would like to be able to convert a numerical matrix into a cell array of strings.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
The following example should illustrate how this can be achieved:
A = rand(1,5)
B = arrayfun(@num2str, A, 'UniformOutput', 0)
The NUM2STR function converts a number to the string representation of that number. This function is applied to each cell in the A array/matrix using ARRAYFUN. The 'UniformOutput' parameter is set to 0 to instruct CELLFUN to encapsulate the outputs into a cell array.
0 Comments
More Answers (0)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!