MATLAB: How to convert a numerical matrix into a cell array of strings in MATLAB

MATLAB

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

Best 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.