# MATLAB: Opening a sequence of text file

text files

hi suppose I have a char array C = [0001.hk 0002.hk]
and suppose I have a text file in my current directory called 0001.txt
I am wondering what are the code using the char array C(1) to open 0001.txt?
thx

• C = [0001.hk 0002.hk]
C = {'0001.hk' '0002.hk'};
C = strrep( C, 'hk', 'txt' )
for i = 1:numel( C )   fid = fopen( C{i} );   % Do something with the fileend