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

I would like to be able to convert a numerical matrix into a cell array of strings.

 Accepted Answer

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

Products

Release

R2006b

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!