Help definitely needed! How do I load multiple txt files and change the varible names of each to include the date from file
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
mashtine
le 13 Fév 2014
Réponse apportée : David Young
le 13 Fév 2014
Hey everyone,
My coding skills have clearly dies on me with this one. I have a few txt files in directory that I am using textscan to load (massive files so I want to reduce memory). I would like a loop that goes through the list, loads in data into the workspace and gives each dataset a variable name that includes the date from the file name.
My file names are like this one midas_wind_198001-198012.txt from 1979-2013.
Here is the code I have thus far for loading but I am stuck on taking it further to renaming the variables. I do not want to use EVAL for efficiency reasons and I would like each dataset to be its own variable
fid = fopen('midas_wind_197701-197712.txt', 'r');
C = textscan(fid,'%s %s %f %f %s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %s %f', 'Delimiter',',');
fclose(fid);
Thanks a lot in advance!!
0 commentaires
Réponse acceptée
David Young
le 13 Fév 2014
Much better to use arrays rather than having different variable names. Have a look at structure arrays and cell arrays in the documentation.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Variables dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!