Filter löschen
Filter löschen

Reagrding reading file name

1 Ansicht (letzte 30 Tage)
Uday
Uday am 23 Aug. 2011
I have some text data file which is from 1970:5:2000 the file name is v_CH_1970_II_1A.txt,
v_CH_1975_II_1A.txt,
v_CH_1980_II_1A.txt.....till 2000.
in the same folder I have some other data which has file name v_CH_1970_II_1A.txt
v_CH_1970_II_1A2.txt
v_CH_1970_II_1A3b.txt
v_CH_1970_II_1A6a.txt ---- ( different 13 files)
v_CH_1975_II_1A.txt
v_CH_1975_II_1A2.txt
v_CH_1975_II_1A3b.txt
v_CH_1975_II_1A6a.txt ---- ( diffrent 13 files)
So I would like to read all major years from 1970:5:2000 same time I want to read data from other 13 different files for individual year e.g for 1970
v_CH_1970_II_1A.txt
v_CH_1970_II_1A2.txt
v_CH_1970_II_1A3b.txt
v_CH_1970_II_1A6a.txt
---- ( diffrent 13 files)
somebody please tell me how I can set for loop so I can read both data sets same time?

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 23 Aug. 2011
for k=1970:5:2000
FileStr=sprintf('v_CH_%d_II_1A*.txt');
Files=dir(FileStr);
for j=1:length(Files)
data=textread(Files(j).name);
end
end
  2 Kommentare
Uday
Uday am 24 Aug. 2011
there are some files in different files
v_CH_1970_II_1A_Exe.txt
v_CH_1970_II_6b.txt
v_CH_1970_II_1b.txt
v_CH_1970_II_7.txt
So the structure of name is not constant , so how I can read in this condition
Fangjun Jiang
Fangjun Jiang am 24 Aug. 2011
Change this line
FileStr=sprintf('v_CH_%d_II_*.txt');

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by