How can I convert a numerical matrix into a cell array of strings in MATLAB?

73 views (last 30 days)

Accepted Answer

MathWorks Support Team
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.

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2006b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!