loading multiple .mat files from current directory

5 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2012-8-14
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 个评论
Walter Roberson
Walter Roberson 2018-9-25
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by