How to loop multiple text files with different filenames ?

Hello,
I have multiple text files with different filenames like x001.txt, where x is varying from a-d. I have imported all the files. How to i loop them for reading the data from each of the text file. Thanks.

Answers (1)

files = dir('*.txt') ;
N = length(files) ;
for i = 1:N
thisfile = files(i).txt ;
% Do what you want
end

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!