invoking GMAT from matlab ...

MATLAB interface, C API, using plugins, other interfaces

invoking GMAT from matlab ...

Postby marchand » Sat Jul 07, 2012 2:28 am

Howdy folks!

When I load the libMatlabInterface plugin, two icons appear on the resources tab in GMAT. One labeled "Matlab" and another "Matlab Server". To run Ex_CallMatlabFunction.script, I right-click on "Matlab Server" and select Start first, then I run the GMAT script. However, I am uncertain as to what the role of the "Matlab" icon is on the resources tab. The only options it gives me, when I right-click on it, are "Open" or "Close". I'm just not sure what exactly it is supposed to "Open" or "Close". Nothing ever seems to happen either way, regardless of whether or not the Matlab Server is running.

On a possibly related note, there is a script file under GmatDevelopment\doc\SystemDocs\ArchitecturalSpecification\script called diffcorrHohmann.m, and others under the matlab folder of the parent directory, which seems to suggest you can basically execute a GMAT script or invoke some GMAT functionality from MATLAB. However, the chapter that would allude to this on the architectural specification, chapter 19, appears to be empty. Does this functionality actually work? If so, can anyone share some insights as to what the steps involved are for getting it to work? Currently, if I start GMAT and then Start MATLAB (R2012a, 32-bit), I get a Matlab system error message as matlab crashes. I've attached a copy of the matlab dump file and an image of the error to this post. Is the "Matlab" icon on the resources tab somehow related to the capability to run GMAT from within MATLAB?

Any insight, or nudge in the right direction, you can provide would be greatly appreciated.
Snapshot of Resources with libMatlabInterface plugin loaded
Matlab Dump File
(13.79 KiB) Downloaded 172 times
Image of Matlab System Error message
Posts: 86
Joined: Tue Feb 21, 2012 2:42 pm

Re: invoking GMAT from matlab ...

Postby jjkparker » Wed Jul 11, 2012 8:27 pm

Here's the short version:

There's two MATLAB interfaces that are both implemented in the one libMatlabInterface plugin:

1. GMAT->MATLAB: This is an officially-supported way to call MATLAB functions from a GMAT script. The "Matlab" GUI element that you point out in your post is related to this interface. As far as I can tell, it just provides a way to open or close the child MATLAB console from within GMAT (right-click the "Matlab" item). You do *not* need the "Matlab Server" for this interface.

2. MATLAB->GMAT: This is an experimental, mostly unused way to run GMAT script commands directly from MATLAB. Steps to get it working:

  1. In MATLAB, add GMAT\matlab and all subdirectories to your path.
  2. Open GMAT
  3. Right-click "Matlab Server" in the resources tree and click "Start". This starts a DDE server inside GMAT (and so is Windows-only).
  4. From MATLAB, run OpenGMAT. This makes the connection.
  5. Now type a GMAT command at the MATLAB prompt: Create Spacecraft aSat
  6. Run BuildGMAT from MATLAB.
  7. GMAT will now have a Spacecraft called MySC.

There are some files in <GMAT>\matlab\gmat_command that mimic the GMAT commands (Create, Propagate, etc.). Those call some general commands in <GMAT>\matlab\gmat_keyword that actually send script lines to GMAT and listen for a response (all over DDE).

The fmincon optimizer uses a technique similar to this (notice the gmat_fmincon folder), but I don't know what's going on internally in libFminconOptimizer.
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

Return to External Interfaces and Plugins

Who is online

Users browsing this forum: No registered users and 1 guest