The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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: 25
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(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));

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.