from Restore previous working directory on MATLAB Startup by Vihang Patil
This simple program will restore the last working directory on resuming MATLAB

finish.m
str = pwd;%store present working directory in the variable str
cd([matlabroot '\work']);%change the current directory to c:\Matlab\R2006b\work
fid = fopen('startup.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 in the startup.m
fprintf(fid,'if strcmp(answer,''Yes'')\n');
fprintf(fid,'cd(''%s'');\n',str);
fprintf(fid,'end');
fclose(fid);%close file

Contact us at files@mathworks.com