How do I loop round and upload a different file name each time using csvread?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have to load in a set number of CSV files and do some analysis on them. I think I have to use num2str but I cant get it working. The file names are called GroupC01, GroupC02, ...., GroupCn. I realise once I go over 10 ill have to change the upload to change both units rather than just the one, I'm planning on putting a new for loop in for when i goes over 10. Any ideas on how to upload the files in a loop? Im also wondering if theres a way so I don't have to use another for loop after the file number goes over 10? Ive pasted my code below, any ideas would be much appreciated as I'm pretty new to this software!
for i=1:setnumber
data = csvread(['groupC0'num2str(i)'.CSV'],6,0);
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
John Atkinson
am 23 Apr. 2013
You can use"dir" to do something a long the lines of:
listing = dir;
for iPart=3:length(listing);
file = listing(iPart).name
data = csvread(file,6,0);
RUNFUNCTION
end
Assuming that all the files are in the current directory. This will upload each of them and run the specified function (or code).
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!