From: Ulf Graewe on 24 Jun 2010 06:19 "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
|
Pages: 1 Prev: Precision of CLOCK and CPUTIME Next: Structures or something else |