### Matlab<->GMAT Interface FAQ

Posted:

**Thu Jul 17, 2008 1:02 pm**How does GMAT open the dll driven Matlab Command Window?

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_external/f39903.html

What do I need to be able to correctly interface with Matlab?

What dlls are needed for Windows to properly open the Matlab Command Window version?

libeng.dll (Main Matlab dll called)

What versions of Matlab does GMAT support?

Extensive testing still needs to be made in order to determine a detailed table of what versions of Matlab will work with GMAT.

GMAT is not currently supporting, as of 7/2008, Matlab versions from R14 and earlier.

There have been known 2007b issues when using the matlab interface with GMAT.

I've been using the Matlab 2007a version with no unexpected issues for a while now.

How many different kinds of connections does GMAT make with Matlab?

1) Matlab -> GMAT interface (Using the Matlab Server Interface object)

2) GMAT -> Matlab interface (Activated by Matlab function calls, Using Matlab Interface object)

3) SQP(fmincon) Solver usage (Activated anytime the SQP(fmincon) solver is used in the Mission Sequence. GMAT->Matlab must be working for this to work

What are the matlab scripts that are in the ./matlab/gmat_* directories for?

gmat_command:

- consists of mostly GMAT specific commands that need to be defined in order for Matlab to be able to run GMAT script lines.

(i.e. GMAT can handle the line [temp = 5]. If you were to put that into Matlab, Matlab would attempt to create a variable temp and set its value equal to 5. In order for Matlab to send that line to gmat the following line is needed: [GMAT temp = 5;]

- there are also non-GMAT commands that are used for misc. purposes. For example the Struct2Str.m file is used to convert Matlab structure information into GMAT script lines. (i.e. In Matlab, a user can use the following lines of Matlab syntax: Spacecraft.X = 5000; Spacecraft.Y = 6760; The structure Spacecraft can be sent over to the Struct2Str function to be converted into GMAT syntax and passed to GMAT. The syntax of the structures have to be the same as the GMAT syntax.

gmat_keyword:

- The matlab files in this directory are for passing information back and forth between gmat and matlab (gmat<->matlab).

gmat_fmincon:

- Needed for the successful running of the SQP(fmincon) solver. SQP(fmincon) solver needs Matlab to be able to run

Where can I post Matlab<->GMAT issues or look for how people solved their Matlab<->GMAT issues?

Currently there is no centralized location for this sort of information. For now post information related to your issues in the Matlab Help sub-forum

What should I do when I get the "Failed to Open Matlab Engine" error message?

1) Make sure you are using a post R14 version of Matlab.

2) Make sure your Windows path includes the latest or version of Matlab you want.

To easily view your Windows path in Windows XP you can do the following:

- Click the Start button

- Click on All Programs -> Accessories -> Command Prompt

- Type the word path into the command prompt and press enter

You should see Matlab folders that contain the bin\win32 directory. If not you need to add the location of the Matlab folders that contain the dlls GMAT needs to your path.

To add it to your path, do the following:

Right-click My Computer and click properties.

In the System Properties window, click on the Advanced tab.

In the Advanced section, click the Environment Variables button.

In the Environment Variables window, highlight the path variable in the Systems Variable section and click edit. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon.

3) It's possible that (on windows at least) Matlab wasn't registered as a COM server.

- Go to your Windows Command Prompt (Start button -> All Programs -> Accessories -> Command Prompt)

- Type in matlab /regserver

- Hit Enter

This will register Matlab as a COM server. After those steps, try running a new session of GMAT and Open Matlab.

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_external/f39903.html

What do I need to be able to correctly interface with Matlab?

- Have Matlab.
- Ensure that Matlab bin and win32 directories are in your Windows Path.

(Mac users visit the following thread: http://gmat.ed-pages.com/forum/viewtopic.php?f=4&t=122)

Example: C:\MATLAB\R2009a\bin\win32;C:\MATLAB\R2009a\bin\ are in your windows path

A quick way to see your windows path is: Start button -> Run -> Type 'cmd' and press Enter -> Type 'path' and press Enter - Check to make sure you have the following directories in your GMAT root exe directory:

./matlab

./matlab/gmat_command

./matlab/gmat_fmincon

./matlab/gmat_keyword - Matlab must have the paths from 2) in your Matlab path. If you have restricted admin privelages on you machine Matlab won't allow you to add the path in the main matlab exe. program. You must create a startup.m file

viewtopic.php?f=14&t=10&p=29

What dlls are needed for Windows to properly open the Matlab Command Window version?

libeng.dll (Main Matlab dll called)

- libmx.dll (Matlab dll)

libut.dll (Matlab dll)

ole32.dll (Source unknown)

kernel32.dll (Windows dll)

msvcr80.dll (Matlab dll)

Several other dlls are also needed that are linked to the dlls mentioned above. I've only shown the first level of dependency to libeng.dll

What versions of Matlab does GMAT support?

Extensive testing still needs to be made in order to determine a detailed table of what versions of Matlab will work with GMAT.

GMAT is not currently supporting, as of 7/2008, Matlab versions from R14 and earlier.

There have been known 2007b issues when using the matlab interface with GMAT.

I've been using the Matlab 2007a version with no unexpected issues for a while now.

How many different kinds of connections does GMAT make with Matlab?

1) Matlab -> GMAT interface (Using the Matlab Server Interface object)

2) GMAT -> Matlab interface (Activated by Matlab function calls, Using Matlab Interface object)

3) SQP(fmincon) Solver usage (Activated anytime the SQP(fmincon) solver is used in the Mission Sequence. GMAT->Matlab must be working for this to work

What are the matlab scripts that are in the ./matlab/gmat_* directories for?

gmat_command:

- consists of mostly GMAT specific commands that need to be defined in order for Matlab to be able to run GMAT script lines.

(i.e. GMAT can handle the line [temp = 5]. If you were to put that into Matlab, Matlab would attempt to create a variable temp and set its value equal to 5. In order for Matlab to send that line to gmat the following line is needed: [GMAT temp = 5;]

- there are also non-GMAT commands that are used for misc. purposes. For example the Struct2Str.m file is used to convert Matlab structure information into GMAT script lines. (i.e. In Matlab, a user can use the following lines of Matlab syntax: Spacecraft.X = 5000; Spacecraft.Y = 6760; The structure Spacecraft can be sent over to the Struct2Str function to be converted into GMAT syntax and passed to GMAT. The syntax of the structures have to be the same as the GMAT syntax.

gmat_keyword:

- The matlab files in this directory are for passing information back and forth between gmat and matlab (gmat<->matlab).

gmat_fmincon:

- Needed for the successful running of the SQP(fmincon) solver. SQP(fmincon) solver needs Matlab to be able to run

Where can I post Matlab<->GMAT issues or look for how people solved their Matlab<->GMAT issues?

Currently there is no centralized location for this sort of information. For now post information related to your issues in the Matlab Help sub-forum

What should I do when I get the "Failed to Open Matlab Engine" error message?

1) Make sure you are using a post R14 version of Matlab.

2) Make sure your Windows path includes the latest or version of Matlab you want.

To easily view your Windows path in Windows XP you can do the following:

- Click the Start button

- Click on All Programs -> Accessories -> Command Prompt

- Type the word path into the command prompt and press enter

You should see Matlab folders that contain the bin\win32 directory. If not you need to add the location of the Matlab folders that contain the dlls GMAT needs to your path.

To add it to your path, do the following:

Right-click My Computer and click properties.

In the System Properties window, click on the Advanced tab.

In the Advanced section, click the Environment Variables button.

In the Environment Variables window, highlight the path variable in the Systems Variable section and click edit. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon.

3) It's possible that (on windows at least) Matlab wasn't registered as a COM server.

- Go to your Windows Command Prompt (Start button -> All Programs -> Accessories -> Command Prompt)

- Type in matlab /regserver

- Hit Enter

This will register Matlab as a COM server. After those steps, try running a new session of GMAT and Open Matlab.