Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matlab command to open all files in a directory

Status
Not open for further replies.

biomedgirl

Bioengineer
Aug 31, 2005
4
Is there a Matlab command that allows the user to choose a directory and can then open all the files in that directory automatically? or is there a way to do it using uigetfile?
 
Replies continue below

Recommended for you

Something like this should work (although I haven't tried so it might need debugging) or at least give you an idea of how to go about it.

You could get the path of the directory 'my_dir' using uigetfile.

Code:
% load all *.mat files in the directory contained in the variable my_dir

mydir = '\matlabfiles\myproject';
files = dir([my_dir '\*.mat']);
for count = 1:length(files)
   load([mydir files(count)]; 
end

% might be "load([mydir files{count}]". 
% I don't have Matlab on this computer to check if you need
% curly braces or round brackets.

M

--
Dr Michael F Platten
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor