MATLAB: Is there a way to get the num2str without spaces

num2strnumber

I have a matrix, a=[1:100]. I want to get a matrix c, with the digits of 1:100. To do so, I first did
b=num2str(a),
which gets me the string version but it has spaces. If it did not have spaces, I could make a loop as follows:
for i=1:size(b,2)
c(i)=b(i);
end
Since the num2str(a) has spaces, I cannot just select the ith element of b and get something meaningful.

Best Answer

Try sprintf():
b = sprintf('%d', a); % If a is an integer.
b = sprintf('%f', a); % If a is a double.