'% 2.0f' adds a leading space on demand only, so you want:' %2.0f'.
But this would be nicer, faster and less confusing:
sprintf('%02.0f-%d %d: % 2.0f', 1, 2, 3, 4)
To get around this ugly space gimmicks, which come from the backward compatibility to times before cell strings have been invented, I'm using a dedicated function to join strings:FEX: CStrCatStr. But this is designed for cell strings and for stringshorzcat works sufficiently without deleting spacessmartly.
Best Answer