Filter löschen
Filter löschen

Load from subfolders in directory

10 Ansichten (letzte 30 Tage)
Joel Schelander
Joel Schelander am 9 Mär. 2021
Bearbeitet: Jan am 9 Mär. 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 Kommentare
Joel Schelander
Joel Schelander am 9 Mär. 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 am 9 Mär. 2021
Bearbeitet: Jan am 9 Mär. 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')

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 9 Mär. 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

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by