Rank: 15912 based on 0 downloads (last 30 days) and 0 files submitted
photo

Andreas Köhler

E-mail
Company/University
Fraunhofer IIS/EAS
Lat/Long
51.151787, 10.415039

Personal Profile:
Professional Interests:
model order reduction / large scale dynamical systems

 

Watch this Author's files

 

Comments and Ratings by Andreas
Updated File Comments Rating
06 Jan 2009 Restore previous working directory on MATLAB Startup This simple program will restore the last working directory on resuming MATLAB Author: Vihang Patil

I made the following modification to finish.m such that my startup.m - which already contains important data - is not overwritten:

%%%%%%% finish.m %%%%%%
str = pwd;%store present working directory in the variable str

% figure out where to put restorewd script
pathstr=userpath;
if(isempty(pathstr))
  pathstr=[matlabroot filesep 'work'];
else
  pathstr=pathstr(1:find(pathstr==pathsep)-1);
end

fid = fopen(fullfile(pathstr,'restorewd.m'),'wt');%open file for writing
fprintf(fid,'answer = questdlg(''Do you want to continue working in the previous working directory'',''Restore Last Working Directory'',''Yes'',''No'',''Default'');\n');%write this and the following 3 lines into restorewd.m
fprintf(fid,'cd(''%s'');\n',str);
fprintf(fid,'end');
fclose(fid);%close file
%fprintf(fid,'end');
fclose(fid);%close file

Now, create or append to your existing startup.m:

if exist('restorewd')==2
  restorewd
end

Contact us at files@mathworks.com