Azzera filtri
Azzera filtri

Reagrding reading file name

1 visualizzazione (ultimi 30 giorni)
Uday
Uday il 23 Ago 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?

Risposte (1)

Fangjun Jiang
Fangjun Jiang il 23 Ago 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 Commenti
Uday
Uday il 24 Ago 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 il 24 Ago 2011
Change this line
FileStr=sprintf('v_CH_%d_II_*.txt');

Accedi per commentare.

Categorie

Scopri di più su Data Import and Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by