Effacer les filtres
Effacer les filtres

Load from subfolders in directory

10 vues (au cours des 30 derniers jours)
Joel Schelander
Joel Schelander le 9 Mar 2021
Modifié(e) : Jan le 9 Mar 2021
I have 429 matrices that needs to be stored in a subfolder, I call it CHARGING
I have 429 timetables hat needs to be stored in a subfolder, I call it TIMETABLES
The directory is the Desktop, where I have created the subfolders
I have issues with loading from these subfolders. I have tried
load 'TIMETABLES/Time1.mat' but that does not work
A follow up question is if it is possible to load the whole subfolder at once? So that I dont have to type load TimeXXX 429 times.
  3 commentaires
Joel Schelander
Joel Schelander le 9 Mar 2021
Error using load
Unable to read file 'TIMETABLES/Time1.mat'. No such file or directory.
Error in DRIVE (line 8)
load 'TIMETABLES/Time1.mat'
Jan
Jan le 9 Mar 2021
Modifié(e) : Jan le 9 Mar 2021
The error message tells you, that there is no folder called "TIMETABLES" inside the current directory or that the file "Time1.mat" does not exist. You can check this:
isfolder('TIMETABLES')
isfile('TIMETABLES/Times1.mat')

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 9 Mar 2021
Are you working with Windows, Linux or MacOS?
What is the path of your Desktop folder?
Desktop = fullfile(getenv('USERPROFILE'), 'Desktop');
Data = load(fullfile(Desktop, 'TIMETABLES', 'Time1.mat'))
FileList = dir(fullfile(Desktop, 'TIMETABLES', '*.mat'));
for iFile = 1:numel(FileList)
File = fullfile(FileList(iFile).folder, FileList(iFile).name);
Data = load(File);
... process or store your data here
end

Plus de réponses (0)

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by