Matlab - Read a list of file namse form an ascii file

Status
Not open for further replies.

kato

Junior Member level 3
Joined
Jun 25, 2007
Messages
26
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,487
Hello,

Here it is what I need to do:

I have a file "filesnames.txt" which includes 3 lines of text:

b:\Quick\Take_Trip\S01_Full_band_optimization.hfss
b:\Quick\Take_Trip\R_01_retrieved.OUT
b:\Quick\Take_Trip\R_01_spar.txt

I need to read these three lines (names of files) into Matlab so I can use them to open/close files, i.e. I need to have

fln(1)='b:\Quick\Take_Trip\S01_Full_band_optimization.hfss'
fln(2)='b:\Quick\Take_Trip\R_01_retrieved.OUT'
fln(3)='b:\Quick\Take_Trip\R_01_spar.txt'

so I can do:
a=dlmread(fln(1));
b=dlmread(fln(2));
c=dlmread(fln93));

Yes, I could simply specify these names in the Matlab code too, but I need to be able to change these names very often (different sets of files), so I want to avoid making mistakes in the main code (mixing names without knowing).

I looked everywhere and did not find a satisfactory solution.

Please advise

Thanks

Kato01
 

fid = fopen('filenames.txt', 'r');
a = textscan(fid, '%s');
fclose(fid)


This will load it to a cell array
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…