From: Roberto on
Ok tnx for rour reaction, but how/where do I put the n=n+1 part? Because all of the variables (except len) are char and you'll still have the same problem... Or I don't really understand your solution ;)

And an elegant solution or not, that doesn't matter. If it works, i'm fine! :)

"Ulf Graewe" <ulf.graewe(a)io-warnemuende.de.skip.this> wrote in message <hvvbep$hjo$1(a)fred.mathworks.com>...
> "Roberto " <ivogrunn(a)hotmail.com> wrote in message <hvvail$l24$1(a)fred.mathworks.com>...
> > Hi,
> >
> > I want to read a bunch of xls-files in excel. The names of the files are:
> > 00000.xls
> > 00001.xls
> > 00002.xls
> > 00003.xls
> > etc etc.
> >
> > I tried the following code, but that doesn't work, because 'n' becomes 0 (and not 00000)...
> > n=00000;
> > for n=1:11399;
> > winopen([n, '.xls']);
> > %this part doesn't matter
> > n=n+1;
> > end
> >
> > Anyone an idea?
> > Tnx!
>
> You can try something like this:
> for n=1:11399
> % convert n to a string
> number = num2str(n);
> % get the length of the string
> len = length(number);
> % the file name template
> fname = '00000';
> % substitute the number into the template
> fname(end-len+1:end) = number;
> % construct the full file name
> fullname = [fname,'xls'];
> % now open the file
> winopen(fullname);
> ...
>
> end
>
> This is a quite simple hack. Maybe, someone else will post a more elegant solution.
>
> cheers