Borrar filtros
Borrar filtros

loading multiple .mat files from current directory

5 visualizaciones (últimos 30 días)
Vijay
Vijay el 14 de Ag. de 2012
Comentada: Walter Roberson el 25 de Sept. de 2018
Hi,
Is there a way to load all the .mat files together into the base workspace?
files = dir('*.mat') gives a structure having details of the .mat files in the directory. But with load files(1).name (may be using a loop), I am not able to load a .mat file from the current folder to base workspace.
Any help is appreciated. Vijay

Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Ag. de 2012
evalin('base', ['load ', files(K).name])
Warning: using this method is prone to clobbering variables in the base workspace, as it does not validate the contents of the .mat file before loading.
  5 comentarios
Areej Nayab
Areej Nayab el 25 de Sept. de 2018
can you please tell name is a key word or what
Walter Roberson
Walter Roberson el 25 de Sept. de 2018
dir() returns a struct array. In current releases, that struct contains fields named
bytes
date
datenum
folder
isfolder
name
In terms of the MATLAB language, these are not considered keywords: they are just what the struct fields are named.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by