3.0

3.0 | 1 rating Rate this file 21 downloads (last 30 days) File Size: 1.37 KB File ID: #19239

Restore previous working directory on MATLAB Startup

by Vihang Patil

 

17 Mar 2008 (Updated 18 Mar 2008)

Code covered by BSD License  

This simple program will restore the last working directory on resuming MATLAB

Download Now | Watch this File

File Information
Description

This simple program will remember your last working directory and will prompt you on resuming MATLAB, whether the user wants to start in the last working directory or not
Just copy the contents of the zip file in the Matlabroot work directory
ex: c:\Matlab\R2006b\work and make sure that its on the path.
i.e type path on MATLAB command prompt and see if the above directory exists in the path. If the "work" directory does not exist on your path, then use the "pathtool" function to add the work directory manually.

MATLAB release MATLAB 7.3 (R2006b)
Zip File Content  
Other Files finish.m,
startup.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
06 Jan 2009 Andreas Köhler

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

Please login to add a comment or rating.
Updates
18 Mar 2008

1.Typo Error removed
2. Updated the Description part

Tag Activity for this File
Tag Applied By Date/Time
path Vihang Patil 22 Oct 2008 09:54:00
directories Vihang Patil 22 Oct 2008 09:54:00
files Vihang Patil 22 Oct 2008 09:54:00
previous working directory Vihang Patil 22 Oct 2008 09:54:00
restore Vihang Patil 22 Oct 2008 09:54:00
resume last working directory Vihang Patil 22 Oct 2008 09:54:00
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com