Path: news.mathworks.com!not-for-mail
From: "Vihang Patil" <vihang_patil@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to change startup directory in Matlab 7.5
Date: Mon, 17 Mar 2008 09:16:04 +0000 (UTC)
Organization: Konem Solutions
Lines: 37
Message-ID: <frlcsk$3lo$1@fred.mathworks.com>
References: <fqv437$s8b$1@fred.mathworks.com>
Reply-To: "Vihang Patil" <vihang_patil@yahoo.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1205745364 3768 172.30.248.37 (17 Mar 2008 09:16:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 17 Mar 2008 09:16:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 413701
Xref: news.mathworks.com comp.soft-sys.matlab:457587


"Irian O" <merlingt1@yahoo.com> wrote in message <fqv437
$s8b$1@fred.mathworks.com>...
> Hi everyone,
> 
> I have been the following commands in one of my codes:
> 
> !matlab -nosplash -r myscript &
> 
> This starts a new instance of Matlab and runs the script 
> "myscript.m". The problem is that when the new Matlab 
> window opens it starts in the default main Matlab 
directory 
> instead on the current or working directory when I ran 
the 
> "!matlab .... command". Does anyone know how I can 
change 
> it so it remembers in which directory the previous 
working 
> directory?
> 

This is what you need
doc startup
doc finish
doc pwd

You will need to code your finish.m file in such  a way 
that when you close/exit matlab, it will execute the code 
in it which has the reference to the present working 
directory or pwd and then it outputs that string of the 
pwd to startup.m file
In your startup file, your code should be something like 
this
cd('<path string generated from finish.m>')
HTH
Vihang