Reputation: 33864
I have a log file with a date, ie:
LOG_20120509_100000.log
(year) (month) (day) _ (hour) (minute) (second)
But imagine that i want to perform the same thing on a set of hourly log files. I want to be able to do this:
for i in 0:23
perform on LOG_20120509_%d0000.log, i
end
But this wont work for the logs with hours of less then 10 oclock because it will become:
LOG_20120509_50000.log
So how can i pad out the zeroes in matlab?
Upvotes: 1
Views: 1629
Reputation: 47089
Your %d
usage suggests that you are using sprintf
or similar to generate the filenames, in that case it would suffice to use %02d
for zero padding the hours.
Upvotes: 6