Thanks! So the only option I have is to use the GMAT C interface. Currently for my application I am calling my custom Matlab functions from GMAT i.e. the GMAT script is acting as the "main" function. I am not sure what is the best way to integrate the C code which will make GMAT C interface calls with the rest of my code. May be I can make a Matlab MEX function for C code which I can call from GMAT script. Any suggestions?

Well, you can access the C interface from C (like from a MEX function), or directly from MATLAB using the loadlibrary function. This second method is what ODTBX uses. If you're curious, you can look at the gmatforces_km.m file they use to see how it works.

As for how to structure it, I guess it depends what you're trying to do. ODTBX uses GMAT solely for the Jacobian, so they start in MATLAB and use MATLAB integrators to do the propagation.

Also, if you really just need the state transition matrix (not the Jacobian), GMAT has that built-in.

Thanks a lot. I think "calllib" Matlab function will work fine for my case too as it is in ODTBX.

I actually need jacobian at this time but I got curious on how to access the state transition matrix in my GMAT script, which I might need later in case I want to implement a custom differential corrector scheme. I understand there is a built-in differential corrector solver in GMAT and it can write its internal state at each iteration in the report file automatically but is it possible to access the state transition matrix value after each iteration in GMAT script? I guess the answer may be same: using the libC interface!