MATLAB: How to read data from different text file in a loop, save in a matrix and plot?

for loopread data

Hello,
For example I have different data file named data1.txt, data2.txt, data3.txt… etc. Now I want to read the data from each text file one by one using a loop and save them in a matrix and then plot. I'm out of my depth here.
Any help would be very much appreciated. Thanks..!!

Best Answer

A regular google will give you ton's of sites. This topic is discussed to death in mathworks.
dinfo = dir('*.txt'); % get the text files from folder
for K = 1 : length(dinfo)
thisfilename = dinfo(K).name; %just the name
%load this file
% thisdata = load(thisfilename);
end
plotting, reading the file depends on how your text file is.