MATLAB: How to create a cell of strings from a vector

mat2cellMATLABsprintf

I have the vector
x = [ 10.027 20.35 50.1 100.002 ]
which I would like to convert to the cell
x = { '10', '20', '50', '100' }.
How can I do this? I know I can use sprintf('%.0f\n', x) to get the formatting I want, but not how to turn the outputs into a cell of strings.

Best Answer

Encapsulate sprintf() into arrayfun():
arrayfun(@(in) sprintf('%.0f', in), x,'un',0)