From: Roberto on
Sry, I made a mistake. It works!!! So i'm fine ;)

TNX!

"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
From: Doug Schwarz on
In article <hvvail$l24$1(a)fred.mathworks.com>,
"Roberto " <ivogrunn(a)hotmail.com> wrote:

> 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!


for n = 1:11399
filename = sprintf('%05d.xls',n);
winopen(filename)
end

but I think you're going to have trouble opening 11,399 files in Excel.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
From: Steven Lord on

"Roberto " <ivogrunn(a)hotmail.com> wrote in message
news: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

*snip*

See Q4.12 in the newsgroup FAQ -- I recommend the DIR approach.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Ulf Graewe on
Doug Schwarz <see(a)sig.for.address.edu> wrote in message
>
> for n = 1:11399
> filename = sprintf('%05d.xls',n);
> winopen(filename)
> end
>
Yes, this is much better than the poor solution I suggested.
From: Ashish Uthama on
On Thu, 24 Jun 2010 06:04:05 -0400, Roberto <ivogrunn(a)hotmail.com> wrote:

> 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!

Look up SPRINTF

sprintf('%06d',1)