MATLAB: How to increment a 4-digit number in a character array

increment numbers in character arraysMATLAB

I've got a 1×4 character array containing a 4-digit number.
IRN = '0050';
I'm looking for a way to increment this number in a for loop. For example, with 3 iterations the output of the for loop would be as follows;
MRN =
0051
0052
0053
Can MATLAB increment numbers, within a character array, in a for loop?

Best Answer

I’m not quite sure what you want.
One approach:
IRN = '0050';
IRN0 = IRN;
for k1 = 1:3
IRN = sprintf('%04d', str2num(IRN0)+k1)
end