Borrar filtros
Borrar filtros

Load from subfolders in directory

10 visualizaciones (últimos 30 días)
Joel Schelander
Joel Schelander el 9 de Mzo. de 2021
Editada: Jan el 9 de Mzo. de 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 comentarios
Joel Schelander
Joel Schelander el 9 de Mzo. de 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 el 9 de Mzo. de 2021
Editada: Jan el 9 de Mzo. de 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')

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 9 de Mzo. de 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

Más respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by