Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to launch a M-File from the command line
Date: Wed, 30 Dec 2009 17:12:20 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 28
Message-ID: <hhg1lk$g21$1@fred.mathworks.com>
References: <hhf00s$885$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1262193140 16449 172.30.248.37 (30 Dec 2009 17:12:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 30 Dec 2009 17:12:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2145619
Xref: news.mathworks.com comp.soft-sys.matlab:595599

Problem solved.

I was able to launch by leaving off the .M extension. The -automation switch prevents the command window from being opened.

Here is an example:

matlab -nosplash -nodesktop -sd "C:\Program Files\MATLAB\R2009b\toolbox\matlab\demos" -automation -r "superquad"

"Amr " <amr_hafez@yahoo.com> wrote in message <hhf00s$885$1@fred.mathworks.com>...
> Hello,
> 
> 
> I am trying to launch a M-File using the Matlab command line. Here is the command line as I enter it:
> 
> matlab -nosplash -nodesktop -sd "C:\Program files\MATLAB\R2009b\toolbox\matlab\demos" -r superquad.m
> 
> Matlab starts up in command line mode, but then gives the following error:
> 
> ??? Undefined variable "superquad" or class "superquad.m".
> 
> 
> Is it because superquad.m is not on the MATLAB path ?  If so, how do I add it to the path? I thought the -sd would take care of that.
> 
> Assuming we can solve the first problem, 2 follow on questions:
> 1) Can I pass a command line argument to the M-File?
> 2) Can I run the M-FIle without displaying the Matlab Command Window?
> 
> Help will be greatly appreciated.