MATLAB: How to format integer numbers to start with filling zeros digitformatintegernumberprintfstringzero I would like to transform n = 1:12 to '01','02',…,'11','12' Best Answer 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. Related SolutionsMATLAB: Replacing “zero dates ” so as to be empty If C is your cell array, thenC = regexprep(C,'00/00/00','') MATLAB: Matrix Filling index = find(A(1,:) == 14); A = cat(1,A,zeros(1,size(A,2))); A(2,index) = 14;Added after Sean's point -- if the integer is not present in the row, you'll just get a row of zeros. index = find(A(1,:) == 59); A = cat(1,A,zeros(1,size(A,2))); A(2,index) = 59; Related QuestionFormatting Time StringsHow to pad zerosErasing specifi rows from a cell matrixFormulating elapsed time in hours for input data…
Best Answer