フィルターのクリア

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.
  1 件のコメント
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 4 月 3 日
Sounds interesting! I would like to know the answer as well.

サインインしてコメントする。

採用された回答

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 Center および File ExchangeFile Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by