Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.straub-nv.de!feeder.eternal-september.org!eternal-september.org!not-for-mail
From: dpb <none@non.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: "Change directory" dialog box
Date: Wed, 07 Oct 2009 12:58:45 -0500
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <hail59$ojp$1@news.eternal-september.org>
References: <haidoe$mjn$1@fred.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.eternal-september.org U2FsdGVkX1/008IAsff4x+ATFU9ELPV8NGUysdn5+XO4gd3yInxEO1EIV96DhwG0NHQMeNfy2t3Q/J6sn3uoY4cP4I5Fcl4gZaw4POBLSucBUPTVHvtMCencpmnRZOlgAwpGmVn/2fe7cLx6CohLmQ==
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Wed, 7 Oct 2009 18:03:22 +0000 (UTC)
In-Reply-To: <haidoe$mjn$1@fred.mathworks.com>
X-Auth-Sender: U2FsdGVkX19B9SG4bzwMWIphjt/ras/nhG0mPcZplf0=
Cancel-Lock: sha1:RdM3uF7mBVYmNnueNtVfO2GoTNQ=
User-Agent: Thunderbird 2.0.0.22 (Windows/20090605)
Xref: news.mathworks.com comp.soft-sys.matlab:575669


Andre Brito wrote:
> Hello,
> 
> is there any way (other than adding a line of code in every file) to
> set the MATLAB preferences such that the default behavior for running
> m-files is to change the current directory to the directory where the
> file is located ?
...

automagically, how is it to know where the m-file is located unless the 
directory containing the m-file is already in the search path or the cwd?

I don't see a way to do this other than by having the m-file make such a 
change on its own which seems a poor idea.

In general, one organizes ML files into project-related directories and 
makes a high-level startup file to set the proper parameters for a given 
project that would include setting working directory, path for 
project-specific files, etc.

OTOH, most users also create their subdirectories of custom functions 
that are more generic that they want available between projects and use 
the preferences files or startup to set the search path for such 
directory(ies).

What, specifically, kind of an issue are you trying to solve--perhaps 
more background would lead to other ideas/solutions others have had for 
similar situations.

--