MATLAB: How to make sure number of digits remain same, padded if required MATLAB I am assigning names in a loop of the form img000.png,img001.png and so on. I’m using strcat as follows: %num=000 %strcat(‘img’,num2str(num),’.png’) %num=+1 How do I make the assignment of num so that it always remains 3 digits? Best Answer Try to use something likeimg_name=sprintf('img%03d',num) instead of the strcat line Related SolutionsMATLAB: MuPAD typeverin the command line and look for symbolic math toolbox. If it's not in the list, then you would have to purchase it MATLAB: How to transform a number to string with space using num2str Hi!Maybe this way?num = [1000; 1001];% numeric partnumpart = arrayfun(@(x) sprintf('%2d', mod(x,100)), num, 'UniformOutput', false);% letter partletterpart = char(mod(num,26*100)./100+65);% concat everythingretsult = strcat(letterpart, numpart) Related QuestionAdding multiple images together from a for loopHow to convert these numbers to vector? size (1*1000)How to pad zeros
Best Answer