Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!news.glorb.com!news.aset.psu.edu!support1.mathforum.org!not-for-mail
From: Bill August <hui.song@beds.ac.uk>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matlab path issues
Date: Wed, 20 Aug 2008 08:56:32 EDT
Organization: The Math Forum
Lines: 133
Message-ID: <16860251.1219237023270.JavaMail.jakarta@nitrogen.mathforum.org>
References: <g8grp6$kbo$1@fred.mathworks.com>
NNTP-Posting-Host: nitrogen.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1219237023 30742 144.118.30.135 (20 Aug 2008 12:57:03 GMT)
X-Complaints-To: news@support1.mathforum.org
NNTP-Posting-Date: Wed, 20 Aug 2008 12:57:03 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:486426



> Thanks for your help.
> 
> However, the problem I now have is something like
> this:
> 
> 1. I have a statement 
> 
> if ~isdeployed
> 
> ...do normal actions
> 
> else
> try
> a=which('file.xls')
> xlswrite((fileparts(a),'\file.xls'),options)
> end
> end
> 
> I have realised the main problem is with the Which
> function.
> 
> Running the application via Matlab gives no problems.
> But 
> running the deployed function with which looks ONLY
> in the 
> CTF archive folder - as file.xls is not located
> there, the 
> application stops.
> 
> I know I can add MAT files to the archive, but XLS
> not.
> 
> There must be a way for the deployed application to
> find a 
> file anywhere on the path and provide the correct
> location 
> text?
> 
> Any ideas
> Thanks
> Matt
> 
> 
> 
> 
> Bill August <hui.song@beds.ac.uk> wrote in message 
> <411948.1219058896499.JavaMail.jakarta@nitrogen.mathfo
> rum.or
> g>...
> > > Hi,
> > > 
> > > I have an application (GUI) that also is compiled
> as
> > > a 
> > > stand-alone executable to be run on other
> machines.
> > > 
> > > 1. The GUI has some functions that require data
> to be
> > > 
> > > saved/called from specific paths, e.g. 
> > > C:/Matlab7.1/work/Results
> > > 
> > > 2. To ensure the data is stored in the correct
> > > folders, I 
> > > use cd pathname, or xlswrite('pathname',data),
> for
> > > example.
> > > 
> > > 3. For some time, I was able to specify the
> pathname
> > > as 
> > > only /Results, and this enabled flexibility - now
> I
> > > get 
> > > error messages (unknown directory) and cannot
> trace
> > > back 
> > > the problem - I now have to use the complete
> > > pathname.
> > > 
> > > 4. When I install the stand-alone executable on a
> new
> > > 
> > > machine, the problem will occur that I do not
> have
> > > the same 
> > > pathname as on the host computer, so when the
> script
> > > cd or 
> > > xlswrite is executed with a specifie path, there
> will
> > > be an 
> > > error.
> > > 
> > > Can anyone think of a way to specify
> > > folders/directories 
> > > that can be generic to any machine? e.g. a
> function
> > > that 
> > > creates a folder "Results" in a common and
> sensible 
> > > location (i.e. the Program location f?r the
> > > executable and 
> > > the work folder for the original -m files).
> > > 
> > > Thanks
> > > Matt
> > Hi
> > To me I always use the global variable.
> > Add these code to the main function, and you can
> use the 
> relative path base on the root dir. 
> > global APP_ROOTDIR ;
> > APP_ROOTDIR = which('APP_Start') ;
> > CWIND_ROOTDIR = fileparts(APP_ROOTDIR) ;
> > if isempty(APP_ROOTDIR)
> >    warning('Please change directory to the root,
> then 
> start it again.') ;
> >     return ;
> > else
> > end
> > 
> > 
> > Message was edited by: Bill August
> > 
> 
> 
Hi Matthew,
Could you read my reply clearly?
I guess the file 'file.xls' has a fixed relative path to the deployed function (exe)?
If so, as long as you know the path (APP_PATH) of the deployed function (exe) then you can directly get the path of you xls file ([APP_PATH, relativepath]). And you DO NOT 'which' function any more...