Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to launch a M-File from the command line

Subject: How to launch a M-File from the command line

From: Amr

Date: 30 Dec, 2009 07:38:04

Message: 1 of 2

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.

Subject: How to launch a M-File from the command line

From: Amr

Date: 30 Dec, 2009 17:12:20

Message: 2 of 2

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.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us