Filter löschen
Filter löschen

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

28 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Dishant Arora
Dishant Arora am 3 Apr. 2014
How can I process a sequence of files? Second method there'd work for you.

Weitere Antworten (2)

Joseph Cheng
Joseph Cheng am 3 Apr. 2014
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.

Jaber Malekzadah
Jaber Malekzadah am 16 Feb. 2015
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 Kommentar
Jos (10584)
Jos (10584) am 16 Feb. 2015
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)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by