Azzera filtri
Azzera filtri

Load from subfolders in directory

10 visualizzazioni (ultimi 30 giorni)
Joel Schelander
Joel Schelander il 9 Mar 2021
Modificato: Jan il 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 Commenti
Joel Schelander
Joel Schelander il 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 il 9 Mar 2021
Modificato: Jan il 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')

Accedi per commentare.

Risposta accettata

Jan
Jan il 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

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by