Path: news.mathworks.com!not-for-mail
From: "Christophe Boudrie" <christophe.boudrie@altran.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to change startup directory in Matlab 7.5
Date: Sun, 16 Mar 2008 17:50:19 +0000 (UTC)
Organization: Altran AIT
Lines: 35
Message-ID: <frjmkr$qru$1@fred.mathworks.com>
References: <fqv437$s8b$1@fred.mathworks.com>
Reply-To: "Christophe Boudrie" <christophe.boudrie@altran.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 1205689819 27518 172.30.248.37 (16 Mar 2008 17:50:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 16 Mar 2008 17:50:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1151199
Xref: news.mathworks.com comp.soft-sys.matlab:457497


"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?
> 
> Thanks!

Hi, you may simply send the command "cd" for cd(pwd) "pwd" 
is current directory when you invoke the new matlab window:
! matlab -r cd(pwd),my_script...

Another way is to specify the full path of the file you 
which to run:
!matlab -r run('C:\my_folder\my_script.m')

Finally, if you whish to control matlab when ran, you can 
use matlab as an automation server: h = actxserver
('matlab.application'), see matlab help for more details.

regards,
chris