Borrar filtros
Borrar filtros

Reagrding reading file name

1 visualización (últimos 30 días)
Uday
Uday el 23 de Ag. de 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?

Respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by