Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Curious
Posts:
2,357
Registered:
12/6/04


Re: Filenames
Posted:
Aug 5, 2014 3:11 PM


"Will " <owill127@gmail.com> wrote in message <lrr5rr$cl4$1@newscl01ah.mathworks.com>... > I am trying to use matlab to analyze some data and export it to excel. My data is in files with identical names except the ending is a number. for example > > text_#1.txt > > There are sometimes thousands of these files. My problem is that matlab processes them in this order > 100 > 10 > 1 > 12 > 13 > etc > > There are far too many files to change manually so I would like to change the files to all the same number of digits using matlab. for example: > > text_#1.txt would change to text_#001.txt > > anyone know how to do it? > > Thanks
Look here:
<<http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F>>
and modify the example using the '0' flag in sprintf shown here:
<<http://www.mathworks.com/help/matlab/ref/sprintf.html#inputarg_formatSpec>>
to zero pad the field width.



