Effacer les filtres
Effacer les filtres

Reagrding reading file name

1 vue (au cours des 30 derniers jours)
Uday
Uday le 23 Août 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?

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 23 Août 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 commentaires
Uday
Uday le 24 Août 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 le 24 Août 2011
Change this line
FileStr=sprintf('v_CH_%d_II_*.txt');

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Import and Analysis dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by