필터 지우기
필터 지우기

loading a mat file using its location, without knowing its name

조회 수: 28 (최근 30일)
leila
leila 2014년 4월 3일
댓글: Jos (10584) 2015년 2월 16일
I have a large group of mat-files with random names, in a specific folder. I want to load them in a for loop, sequentially.
Is it possible to load them without entering all of file-names in my code?
I really appreciate any help you can provide.

채택된 답변

Dishant Arora
Dishant Arora 2014년 4월 3일
How can I process a sequence of files? Second method there'd work for you.

추가 답변 (2개)

Joseph Cheng
Joseph Cheng 2014년 4월 3일
The dir() command is what you are looking for. such that you can do
MATfiles = dir('c:\testfolder\*.mat');
which will return a structure (here i define as MATfiles) containing all matfiles inside that folder under MATfiles(i).name.
  댓글 수: 1
leila
leila 2014년 4월 3일
Thank you very much. Yes, the dir() command is the correct answer.

댓글을 달려면 로그인하십시오.


Jaber Malekzadah
Jaber Malekzadah 2015년 2월 16일
Hi,
I use the following code but it doesn't work, do you know why?
datapath = 'D:\\Dropbox\PA_imaging\'; MATfiles = dir('datapath*.mat');
I have to use this form code. thanks
  댓글 수: 1
Jos (10584)
Jos (10584) 2015년 2월 16일
What do you mean, "it does not work"? Do you get an error? Do you see too many files? Does the world stop spinning?
datapath = 'D:\\Dropbox\PA_imaging\'
GenericName = fullfile(datapath,'*.mat')
MATfiles = dir(GenericName)

댓글을 달려면 로그인하십시오.

카테고리

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