Search Blogs Blogs

My tips for using the STK Object Model with MATLAB

By: Patrick Ortenzio

The capabilities of AGI products can be extended by integrating our technology with programming environments, such as MATLAB, Python, and various C# platforms. Many STK users leverage the Object Model programming architecture to automate their analyses with MATLAB, but aren’t sure where to begin when it comes to connecting with scenario objects and executing a variety of simulation and data analysis functions. In this post, I will share a few tips and tricks to take your (MATLAB) STK automation game to the next level. 

Tip 1. Check out MATLAB code snippets available online

When it comes to automating your STK analysis with MATLAB, it can be hard to know where to start. Luckily, we have a variety of code snippets posted online to get you started! These code snippets will help clarify the syntax and workflow for many Object Model commands, and can be a valuable resource for you as you begin automating STK with MATLAB. Links to code snippet listings for MATLAB and several other programming languages can be found here

A variety of code examples have been written by AGI engineers and posted on our Code Examples Page. These can help you quickly accomplish more specific and complex tasks. These samples can be filtered by programming language, product, and topic to help you find what you need.  

Tip 2. Code side-by-side with the STK GUI

When automating STK with MATLAB, I find it helpful to have the STK GUI open at the same time. This is because the workflow for completing tasks using Object Model commands often parallels the workflow for completing tasks in the GUI. On the MATLAB code snippets page, you can find the following example, which adds a minimum altitude access constraint: 

One thing to note is the order of operations when the constraint value is set. If you were to set this constraint in the GUI, you would first need to click the checkbox to enable a minimum altitude in the parent object’s constraint settings. The logic in controlling STK through MATLAB parallels the logic in the GUI, so the "checkbox" needs to be enabled here, too. 

Tip 3. Create a library of MATLAB functions to simplify common tasks 

Having a library of MATLAB functions that will connect to your STK scenario, create analysis workbench vectors, compute access between objects, and perform a variety of other common tasks will certainly come in handy. These functions will keep your analysis moving forward and will save you from relying on an old MATLAB script to serve as a template. 

Tip 4. Find the right commands with STK Object Model online help 

If you were to grab an STK satellite object handle (satellite) in MATLAB, and type satellite in the command window, you would see the following: 

>> satellite
satellite =

MATLAB returns the interface associated with the satellite object (IAgSatellite in this case). If you copy and paste IAgSatellite into the search bar on the STK programming help page, you'll find the IAgSatellite interface page. This page includes an object model tree and a listing of all the methods and properties associated with IAgSatellite objects. The object model tree and the method/property descriptions on this page can be used to find all the ways to interact with your IAgSatellite object using MATLAB. 

Tip 5. Check out code sample resources that come with the STK install

A number of additional resources come with the STK install and are located in your STK program directory (typically C:\Program Files\AGI\STK 11). Among these resources is a CodeSamples folder which includes STK automation examples using MATLAB, C# and Java.

These examples provide detailed, comprehensive workflows for operating STK programmatically, and consider various modules, including Analysis Workbench, Astrogator and others.

Hopefully, these tips will help you effectively conduct your STK analysis with MATLAB (or another programming language). As always, our support engineers are happy to help with any questions you may have, and can be reached by phone at 1-800-924-7244 or 1-610-981-8888, and via email at Happy coding! 

Posted: 3/4/2019 8:00:00 AM