MATLAB: How to convert some numbers to strings with the max length convert for example, I want to convert 1 to 32 to strings length 2, if shorter, '0's are added to the front of the strings. 1 -> '01', 2 -> '02', …, 32 -> '32'. Best Answer str = sprintf('%2.2d', yourInteger) Related SolutionsMATLAB: How to format integer numbers to start with filling zeros This only makes context in terms of strings, in which case sprintf makes this easy:>> sprintf('%02d ',1:12)ans = 01 02 03 04 05 06 07 08 09 10 11 12And if you want them in a cell array just use strsplit on it, or cellstr. MATLAB: How to convert string to double with powers str2double( regexprep('0.88D+02', 'D', 'E') ) Related QuestionHow to randomly change a digit in a stringHow to convert these numbers to vector? size (1*1000)Function to chop a decimal to a variable number of digitsExtract value in cell array based onHow to create a cell of strings from a vector
Best Answer