Prev: Is there a MATLAB function similiar to TableCurve or FindGraph?
Next: write uitable data to text file
From: Khanh on 9 Aug 2010 12:00 I have the same file name that are in different folder. i.e c:/run1/file.txt c:/run2/file.txt c:/run3/file.txt .... I want to read each file.txt and take a value from them. What code do I need to use to call folder names automatically?
From: ImageAnalyst on 9 Aug 2010 12:44 On Aug 9, 12:00 pm, "Khanh " <kdc...(a)mtu.edu> wrote: > I have the same file name that are in different folder. i.e > c:/run1/file.txt > c:/run2/file.txt > c:/run3/file.txt > ... > I want to read each file.txt and take a value from them. What code do I need to use to call folder names automatically? ------------------------------------------------------ Use sprintf() inside a loop to build up your foldernames or filenames. E.g. for k = 1:3 filename = sprintf('c:/run%d/file.txt', k) % Then use csvread, dlmread, fgetl, or whatever is best. end
From: Steven_Lord on 9 Aug 2010 12:49 "Khanh " <kdcung(a)mtu.edu> wrote in message news:i3p8mm$s7a$1(a)fred.mathworks.com... > I have the same file name that are in different folder. i.e > c:/run1/file.txt > c:/run2/file.txt > c:/run3/file.txt > ... > I want to read each file.txt and take a value from them. What code do I > need to use to call folder names automatically? See Q4.12 in the newsgroup FAQ. The same techniques you can use to iterate over file names can be used to iterate over directory names. -- 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: Khanh on 9 Aug 2010 13:29
"Steven_Lord" <slord(a)mathworks.com> wrote in message <i3pbi9$3v0$1(a)fred.mathworks.com>... > > > "Khanh " <kdcung(a)mtu.edu> wrote in message > news:i3p8mm$s7a$1(a)fred.mathworks.com... > > I have the same file name that are in different folder. i.e > > c:/run1/file.txt > > c:/run2/file.txt > > c:/run3/file.txt > > ... > > I want to read each file.txt and take a value from them. What code do I > > need to use to call folder names automatically? > > See Q4.12 in the newsgroup FAQ. The same techniques you can use to iterate > over file names can be used to iterate over directory names. > > -- > 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 Thank you. I got it. > http://www.mathworks.com |