function addallpaths % /*kinda obsolete*/ not at all - LVK 08/11/2002 % adds all the paths in /*rootstr*/ mymatlab global my_matlab_path global dir_delimchar rootstr = 'matlab_work'; mymatlab = 'general_purpose'; curloc = pwd; x = findstr(curloc,rootstr); if isempty(x) warning(['Call to addp outside of ',rootstr,'; the call is ignored']); else delimchar = curloc(x-1); dir_delimchar = delimchar; the_path = curloc(1:x+length(rootstr)-1); my_matlab_path = the_path; addpath(my_matlab_path); path1 = [the_path,delimchar,mymatlab]; %addpath(path1); %visit_all_subdirs_g(the_path, 'addpcurdir',delimchar); %visit_all_subdirs_g(the_path, 'addpcurdirifnottrash',delimchar); visit_all_subdirs_g(path1, 'addpcurdirifnottrash',delimchar); end % make sure my_matlab_path does NOT end with delimchar if (my_matlab_path(end)==delimchar) my_matlab_path = my_matlab_path(1:end-1); end % add some frequently used paths addmypath('matlab_c') addmypath('hmm') addmypath('learning') addmypath('fsa') return function visit_all_subdirs_g(startloc, action,ddelim) oldloc = pwd; cd(startloc); dir_struc = dir; fprintf('Visited %s; action = %s \n',startloc,action); eval(action); for j=3:length(dir_struc) dname = dir_struc(j).name; if isdir(dname) if gooddir(dname) visit_all_subdirs_g([startloc,ddelim,dname], action, ddelim); end end end cd(oldloc); return function b = isprefix(pref,str) % is pref a prefix of str? str = str(1:min(length(str),length(pref))); b = strcmp([str,' '],[pref,' ']); % padding to circumvent Matlab's bug return function b = gooddir(dname) b = 1; b = b & ~isprefix('.',dname); return %-------------------various actions to be taken---------------------------- function addpcurdir p = pwd; addpath(p); return function addpcurdirifnottrash p = pwd; %if ~issuffix('trash',p) if isempty(findstr(p,'trash')) addpath(p); %disp('added') end return function b = issuffix(suff,str) % is suff a suffix of str? ml = min(length(str),length(suff)); str = str(end-ml+1:end); %b = strcmp([str,' '],[suff,' ']); % padding to circumvent Matlab's bug b = isequal([str,' '],[suff,' ']); % padding to circumvent Matlab's bug return