loading multiple .mat files from current directory

조회 수: 1 (최근 30일)
Vijay
Vijay 2012년 8월 14일
댓글: Walter Roberson 2018년 9월 25일
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
Areej Nayab
Areej Nayab 2018년 9월 25일
can you please tell name is a key word or what
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에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by