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$>
References: <hhf00s$885$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1262193140 16449 (30 Dec 2009 17:12:20 GMT)
NNTP-Posting-Date: Wed, 30 Dec 2009 17:12:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2145619
Xref: 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 " <> wrote in message <hhf00s$885$>...
> 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.