How to import specific columns from multiple text files into a single numeric array?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Marcella Roth
am 26 Jan. 2021
Kommentiert: Marcella Roth
am 27 Jan. 2021
Hi,
I am extremely new to Matlab and have a question on how to import specific columns from multiple text files into a single numeric array. I have 5 text files all in a single directory. I would like to read in the second column of numbers from each of these 5 files into a single numeric array and export that array to a new text file with a new name. Is there a simple way to do this?
Thanks!
0 Kommentare
Akzeptierte Antwort
David Hill
am 26 Jan. 2021
newFile=[];
for k=1:5
a=readmatrix(sprintf('yourFile%d.txt',k));%name files consistently with number at end
newFile=[newFile;a(:,2)];
end
save('newFile.txt','newFile','-ascii');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Low-Level File I/O finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!