×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Matlab command to open all files in a directory

Matlab command to open all files in a directory

Matlab command to open all files in a directory

(OP)
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?

RE: Matlab command to open all files in a directory

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources