From: Khanh on 10 Aug 2010 09:49 So I have some files that I want to read all with 'sprintf'. If those files are named test1.txt, test2.txt, test3.txt... then I have no problem using for k=1:n sprintf('c:/folder/test%d.txt',k) But if my files are name like text_0001.txt, text_0002.txt, and so on, I have not figured out away to use sprintf function to read those files. Any suggestions?
From: dpb on 10 Aug 2010 10:10 Khanh wrote: > So I have some files that I want to read all with 'sprintf'. If those > files are named test1.txt, test2.txt, test3.txt... then I have no > problem using for k=1:n > sprintf('c:/folder/test%d.txt',k) > > But if my files are name like text_0001.txt, text_0002.txt, and so on, I > have not figured out away to use sprintf function to read those files. > Any suggestions? doc dir --
From: Walter Roberson on 10 Aug 2010 18:43 dpb wrote: > Khanh wrote: >> So I have some files that I want to read all with 'sprintf'. If those >> files are named test1.txt, test2.txt, test3.txt... then I have no >> problem using for k=1:n >> sprintf('c:/folder/test%d.txt',k) >> >> But if my files are name like text_0001.txt, text_0002.txt, and so on, >> I have not figured out away to use sprintf function to read those files. >> Any suggestions? > > doc dir sprintf('C:/folder/test%04d.txt',k)
From: Khanh on 12 Aug 2010 12:52 Walter Roberson <roberson(a)hushmail.com> wrote in message <i3skm9$c6q$4(a)canopus.cc.umanitoba.ca>... > dpb wrote: > > Khanh wrote: > >> So I have some files that I want to read all with 'sprintf'. If those > >> files are named test1.txt, test2.txt, test3.txt... then I have no > >> problem using for k=1:n > >> sprintf('c:/folder/test%d.txt',k) > >> > >> But if my files are name like text_0001.txt, text_0002.txt, and so on, > >> I have not figured out away to use sprintf function to read those files. > >> Any suggestions? > > > > doc dir > > sprintf('C:/folder/test%04d.txt',k) this does not solve the problem. How can you make it skip the "_" and all the zeroes. If the text file goes up to like text_0012.txt, ...text_0112.txt,...
From: Walter Roberson on 12 Aug 2010 13:02 Khanh wrote: > Walter Roberson <roberson(a)hushmail.com> wrote in message > <i3skm9$c6q$4(a)canopus.cc.umanitoba.ca>... >> dpb wrote: >> > Khanh wrote: >> >> So I have some files that I want to read all with 'sprintf'. If >> those >> files are named test1.txt, test2.txt, test3.txt... then I >> have no >> problem using for k=1:n >> >> sprintf('c:/folder/test%d.txt',k) >> >> >> >> But if my files are name like text_0001.txt, text_0002.txt, and so >> on, >> I have not figured out away to use sprintf function to read >> those files. >> >> Any suggestions? >> > > doc dir >> >> sprintf('C:/folder/test%04d.txt',k) > > this does not solve the problem. How can you make it skip the "_" and > all the zeroes. > If the text file goes up to like text_0012.txt, ...text_0112.txt,... Sorry, make that sprintf('C:/folder/test_%04d.txt',k) And if that isn't a sufficient answer to your question, then I would question how it is that you expect a function that formats strings for output to be able to *read* files. Have you considered dir('C:/folder/test_*.txt') ?
|
Next
|
Last
Pages: 1 2 3 Prev: matrix-vector vs. vector-matrix multiplication Next: Reading a PDF file |