I'm not super fluent in the GMAT MATLAB API, but I am familiar with the Python API and I think most of the functional commands operate in the same way. To run what you want in python, you could do:
import sys
sys.path.append("/path/to/gmat/bin")
sys.path.append("/path/to/gmat/api")
script_path = "/path/to/gmat/script"
from load_gmat import * # equivalent to load_gmat
def run_gmat(inclination): # This would be your RunGmat function
did_load = gmat.LoadScript(script_path) # Load fresh for each run
if did_load is False: # Check if load failed
print('Script failed to load')
return
sat = gmat.GetObject("DefaultSC") # Can replace DefaultSC with spacecraft name
sat.SetField('INC', inclination) # Set the Satellites INC parameter
gmat.Initialize() # May not be necessary since loading a script
did_run = gmat.RunScript() # Run script with new INC value
if did_run is False: # Check if run failed
print('Script failed to run')
return
else:
print('Script ran successfully, INC=', inclination)
return
for inclination in range(0, 360, 5):
run_gmat(inclination) # Can iterate
This is a pretty basic implementation of looping through values. If you want to retrieve any values after a run, you can use the GetRuntimeObject
call in the same way I used the GetObject
call on both objects and variables.
As I mentioned, not super fluent in how the MATLAB interface works, but I assume the same function would look something like:
function did_run = RunGmat(inclination)
load_gmat
did_load = GMATAPI.LoadScript('/path/to/script');
if did_load == false
disp('failed to load');
return
end
sat = GMATAPI.GetObject("DefaultSC");
sat.SetField('INC', inclination);
did_run = GMATAPI.RunScript();
if did_run == false
disp('failed to run');
else
disp("successfully ran");
end