Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: load files from subdirectories
Replies: 1   Last Post: Mar 5, 2013 10:12 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Abdul Rauf Anwar

Posts: 22
Registered: 11/21/09
load files from subdirectories
Posted: Mar 5, 2013 5:32 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I am trying to open file BG.mat, which is present in most of the subfolders. And i want to load contents of this file in workspace. I tried using the following code, its second last line is giving me problem. Any comments would be appreciated. Thanks

filetofind = 'BG.mat';
dirinfo = dir(); dirinfo(~[dirinfo.isdir]) = []; %remove non-directories
tf = ismember( {dirinfo.name}, {'.', '..'});
dirinfo(tf) = []; %remove current and parent directory.
numsubdir = length(dirinfo);
lastmod = inf * ones(numsubdir,1);
for K = 1 : numsubdir
subdirinfo = dir(fullfile(dirinfo(K).name, filetofind));
load subdirinfo.name
end



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.