Matlab<->GMAT Interface FAQ

MATLAB-specific help discussions.

Matlab<->GMAT Interface FAQ

Postby space_egd » Thu Jul 17, 2008 1:02 pm

How does GMAT open the dll driven Matlab Command Window?

What do I need to be able to correctly interface with Matlab?
  1. Have Matlab. ;)
  2. Ensure that Matlab bin and win32 directories are in your Windows Path.
    (Mac users visit the following thread:
    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
  3. Check to make sure you have the following directories in your GMAT root exe directory:
  4. 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

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?
- 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.

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

- 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.
Last edited by space_egd on Mon Jun 07, 2010 2:36 pm, edited 7 times in total.
Reason: Added text stating that certain Matlab directories need to be in a users Windows path
Posts: 357
Joined: Sun Jun 08, 2008 9:02 pm
Location: MD

Re: Matlab<->GMAT Interface FAQ

Postby swapan » Mon Jan 05, 2009 5:49 pm

Do the Linux/Mac builds of GMAT currently work with MATLAB? Looking at the '.m' files in the /bin/matlab directory of the Linux,Mac and Platform independent distrabutions it seems like it is currently not supported. Any suggestions on how to get this interface working.
Thanks, Swapan Gandhi.
Posts: 6
Joined: Tue Oct 21, 2008 9:45 pm

Re: Matlab<->GMAT Interface FAQ

Postby space_egd » Mon Jan 05, 2009 7:21 pm

The Linux and Mac versions of GMAT have limited Matlab functionality when compared to the Windows version.

Out of the available GMAT <-> Matlab interfaces the Linux and Mac versions only suport the following types:
GMAT -> Matlab interface (Activated by Matlab function calls, Using Matlab Interface object)

Linux/Mac versions can not run SQP(fminon) solver scripts or have Matlab run GMAT.

We will be working on adding these capabilities into the next public release.
Posts: 357
Joined: Sun Jun 08, 2008 9:02 pm
Location: MD

Re: Matlab<->GMAT Interface FAQ -R2009a

Postby cheetham » Thu Jul 23, 2009 10:22 pm

I had to update today to Matlab 2009a and since - have not been able to run GMAT <-> matlab connection.

I checked path and everything is set. I am wondering if there are compatibility issues with 2009a and if there are any solutions.

Posts: 9
Joined: Wed Jul 15, 2009 8:11 pm

Re: Matlab<->GMAT Interface FAQ

Postby space_egd » Fri Jul 24, 2009 3:20 am

I also recently upgraded to Matlab 2009a.

Initially, I noticed that scripts I ran that had Matlab functions in them didn't open the Matlab command window as they should. I manually tried to open the Matlab command window in GMAT by right clicking the Matlab icon and selecting Open. I did this several times before the Matlab command window appeared. Once it appeared the first time, I've never had a problem with scripts opening the Matlab command window. I haven't tried running GMAT from Matlab yet though.

Do you only have one Matlab version installed?
Posts: 357
Joined: Sun Jun 08, 2008 9:02 pm
Location: MD

Re: Matlab<->GMAT Interface FAQ

Postby cheetham » Fri Jul 24, 2009 4:30 pm

Thanks Edwin - after a restart and some persistence (manually trying to open matlab a few times) it appears that they are working together again. Phew!!

Posts: 9
Joined: Wed Jul 15, 2009 8:11 pm

Re: Matlab<->GMAT Interface FAQ

Postby Poisonous » Fri Aug 12, 2011 9:40 am

Have the limitations for Linux been overcome? I'm thinking over switching to Linux and don't want to be limited )
Posts: 1
Joined: Fri Aug 12, 2011 9:35 am

Re: Matlab<->GMAT Interface FAQ

Postby kstephens » Wed Sep 07, 2011 1:44 pm

I've been trying to obtain the .m files from the "Running GMAT Scripts form MATLAB" topic in the documentation but continue to get the following error:

"An error has been encountered in accessing this page.

1. Server:
2. URL path: /docs/R2011a/html/scripts/runMatlabToGMAT.m
3. Error notes: NONE
4. Error type: 404
5. Request method: GET
6. Request query string: NONE
7. Time: 2011-09-07 13:41:18 UTC (1315402878)

Reporting this problem: The problem you have encountered is with a project web site hosted by This issue should be reported to the project (not to

If this is a severe or recurring/persistent problem, please do one of the following, and provide the error text (numbered 1 through 7, above):

Contact the project via their designated support resources.
Contact the project administrators of this project via email (see the upper right-hand corner of the Project Summary page for their usernames) at
If you are a maintainer of this web content, please refer to the Site Documentation regarding web services for further assistance.

NOTE: As of 2008-10-23 directory index display has been disabled by default. This option may be re-enabled by the project by placing a file with the name ".htaccess" with this line:

Options +Indexes"

How can I obtain these .m files? I'm working on a project that needs them as the "missing link" to completion.

Thank you.
Posts: 2
Joined: Wed Sep 07, 2011 1:38 pm

Re: Matlab<->GMAT Interface FAQ

Postby jjkparker » Wed Sep 07, 2011 6:49 pm

Joel J. K. Parker
Flight dynamics engineer, GMAT team
Posts: 617
Joined: Thu Jan 07, 2010 9:48 pm
Location: NASA Goddard Space Flight Center, Greenbelt, MD

Re: Matlab<->GMAT Interface FAQ

Postby kstephens » Wed Sep 07, 2011 7:29 pm

Thanks so much!
Posts: 2
Joined: Wed Sep 07, 2011 1:38 pm


Return to MATLAB Help

Who is online

Users browsing this forum: No registered users and 1 guest