I kknow I can pad a number up to 3 digits this way:
prematrix = sprintf('%03d', prematrix);
but what if I want a number of digits stored in a for example?
a
I don't know Matlab, but just googled strcat and this should work (untested) for 12 zeros:
a='%0'; b='12'; c='d'; d=strcat(a,b,c); prematrix = sprintf(d, prematrix);