How to read data from different text file in a loop, save in a matrix and plot??
Mostrar comentarios más antiguos
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..!!
Respuesta aceptada
Más respuestas (1)
If you want to import the files in alphanumeric order than you could download my FEX submission natsortfiles, and use the examples to base your code on:
P = 'C:\Test'; % directory path
S = dir(fullfile(P,'data*.txt'));
S = natsortfiles(S);
for k = 1:numel(S)
F = fullfile(P,S(k).name)
... your code here
end
Categorías
Más información sobre Text Files en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!