How to import multiple txt files in different folders into workspace at one time?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
anone
am 18 Sep. 2014
Kommentiert: Stephen23
am 19 Sep. 2014
Hi, I have multiple txt files stored in several folders and the groups of txt files in the same folder has a similar pattern of file names. All the txt files need to be read starting from the 3rd row. How can I import all the txt files from the different folders at one time into MATLAB workspace and then assign them with different names in the workspace?
Many thanks,
a sincerely user
1 Kommentar
Stephen23
am 19 Sep. 2014
Do not create or use variable names dynamically like this. Use a cell array or structure instead:
Akzeptierte Antwort
Mohammad Abouali
am 18 Sep. 2014
have you tried "textread" command? It has a headerline parameter that tells how many line to ignore. You need to call that function for each file though.
2 Kommentare
Mohammad Abouali
am 19 Sep. 2014
I wouldn't name them differently. but you can use cell arrays something like this:
for i=1:nFiles
[A,B,C,...]=textread(....);
myData.A{i}=A;
myData.B{i}=B;
myData.C{i}=C;
end
Then you can access the values from different file easily or later you can combine them together.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Files and Folders 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!