Part 13: Integrating STK with MATLAB

STK Pro, STK Premium (Air), STK Premium (Space), or STK Enterprise
You can obtain the necessary licenses for this training by contacting AGI Support at support@agi.com or 1-800-924-7244.

You need to install MATLAB on your computer to complete this tutorial. Version R2023a was used in this tutorial. Your version might have different tools and procedures.

Capabilities covered

This lesson covers the following STK capabilities:

  • STK Pro
  • STK Integration

Problem statement

If you are a developer, engineer, or operator, you need to do the following tasks quickly and easily:

  • Automate repetitive tasks from outside of the STK application
  • Integrate STK with other applications, such as MATLAB, Microsoft Excel, and Python
  • Develop custom applications
  • Leverage the AGI Object Model collection of COM libraries from other applications

You want to be able to create, drive, and extract data from an STK scenario using MATLAB. To do so, you need to understand access to the following Application Programming Interfaces (API): the STK Object Model and Connect. You also need a basic understanding of the structure and contents of the STK Programming Help.

Solution

Using STK, including the STK Integration capability, and MATLAB, create a new instance of STK and expose the object root. Next, build a new scenario, populating it with a Satellite () object and a Target () object. Create an access between the Satellite object and the Target object, extracting access times from STK and moving them into MATLAB. Use the correct data providers, both groups and elements, to determine a precision pass value at a specific time in the scenario. Learn the benefits of the STK Programming Help.

What you will learn

Upon completion of this tutorial, you will have a basic understanding the following:

  • STK Programming Help
  • STK Object Model
  • Connect
  • MATLAB code snippets
  • MATLAB Connect code snippets
  • Data providers

You should shut down STK and MATLAB prior to starting this tutorial. This tutorial isn't designed to teach you how to use MATLAB. It's an introduction to integrating MATLAB with STK and pulling data from STK into MATLAB. It's also an introduction to the STK Programming Help and how important it is to be able to intelligently browse these help pages.

Video guidance

Watch the following video. Then follow the steps below, which incorporate the systems and missions you work on (sample inputs provided).

Accessing the STK Programming Help

The STK Programming Help offers a wide variety of options to automate and customize STK and to integrate its technology into other applications. This tutorial covers only a small portion of the STK Programming Help, but you get a great starting point from which to branch out.

  1. Open your preferred internet browser.
  2. Go to help.agi.com.
  3. Click STK Programming Help.

Integrating with other applications

STK’s Integration capability enables you to automate repetitive tasks from outside the STK application, integrate STK with other applications such as MATLAB and Microsoft Excel, develop custom applications, and leverage the AGI Object Model collection of COM libraries from other applications. Follow these steps to learn more about these possibilities.

  1. Click Select the Right Technology in the table of contents of the STK Programming Help.
  2. Select Integrate Technologies.
  3. Select clickable decision tree on the Integrate With Other Applications topic page.
  4. Take some time to view the page and click some of the icons.
  5. There are many clickable decision trees available in STK Programming Help. You can use the trees to quickly locate help pages that you need to be successful when integrating with STK.

Automating repetitive tasks

To automate repetitive tasks in STK, you can use HTML, Connect, and STK Objects to build tools that are accessible from within STK. You can find more information on this in the STK Programming Help by following these steps:

  1. Under Select the Right Technology, click Automate Tasks.
  2. Select clickable decision tree on the Automate Repetitive Tasks topic page.
  3. Take some time to view the page and click some of the icons.

Extending AGI products

AGI provides a variety of ways to extend its products. These extensibility mechanisms come under two distinct categories: user interface extensibility and engine extensibility. You can find more information on these in the STK Programming Help by following these steps:

  1. Under Select the Right Technology, click Extend AGI Products.
  2. Click clickable decision tree on the Extend AGI Products Using Plugins and Custom User Interfaces topic page.
  3. Take some time to view the page and click some of the icons.
  4. There are other links throughout that aren't covered here. Take some time later on to become familiar with them.

Visualizing in STK

STK X enables developers to add advanced STK 2D and 3D visualization and analytical capabilities to applications with little effort. You can find more information on this in the STK Programming Help by following these steps:

  1. In the table of contents, go to Library Reference > Controls > STK X.
  2. Take some time to familiarize yourself with the contents of this page.

Using core libraries

The STK API consists of two major subsystems: Connect and the STK Object Model.

Core Libraries

  1. In the STK Programming Help, click Using Core Libraries in the table of contents.
  2. Note the advantages and disadvantages of using the Connect and Object Model libraries.
  3. Choosing either Connect or Object Model should be driven by the requirements of the application and your needs as a developer. However, this need not be an exclusive choice. You can use Connect commands in a COM application side by side with Object Model code.

Learning STK Object Model naming conventions

The STK Object Model contains naming conventions for classes, interfaces, and enumerations.

Naming Conventions

  1. In the STK Programming Help, go to Library Reference > STK Object Model > Naming Conventions.
  2. Note the various naming conventions described in the Naming Conventions Used in the Various Core Libraries topic.
  3. Click the certain abbreviations link.
  4. Note the abbreviations most commonly used in the names of classes, interfaces, and other types in the STK Object Model.

Using model diagrams

As a serious programmer, you can use diagrams to see how the STK traffic flow is connected. That way, you know what's to the right, left, above, and below, all while deep linking to the individual IAg interface pages.

  1. In the STK Programming Help, go to Using Core Libraries > STK Object Model > STK Objects > Diagrams.
  2. Click STK Object Model Diagram (PDF) in the STK Objects Object Model Diagrams topic.
  3. Zoom in closer to the page for clarification.
  4. Take some time to look at the STK 10.0 Object Model Diagrams PDF.
  5. A Diagrams topic (with PDF links) exists for each of the following topic folders in the Using Core Libraries folder:

    • STK Objects
    • STK X
    • STK VGT (Analysis Workbench)
    • STK Util
    • STK Astrogator
  6. Close the STK Object Model Diagram (PDF) when finished.
  7. Keep the STK Programming Help open.

Launching MATLAB

MATLAB is a programming and numeric computing platform used by millions of engineers and scientists to analyze data, develop algorithms, and create models.

  1. Launch MATLAB.
  2. Select the Home tab when MATLAB opens.
  3. Click Layout in the MATLAB Toolstrip.
  4. Select Default in the Select Layout menu. This makes it easier to follow the tutorial. If you're familiar with MATLAB and have a setup you prefer, keep it.

Creating a new script

MATLAB script files are program files with the .m extension. In these files, you can write groups of commands that you want to execute together. Scripts do not accept inputs and do not return any outputs. They operate on data in the workspace. Scripts are the simplest kind of program file because they have no input or output arguments. After creating a script file for this tutorial, you can use it later to practice with.

  1. Select the Home tab in the MATLAB Toolstrip.
  2. Click New Script.
  3. Select the Editor tab in the MATLAB Toolstrip.
  4. Open the Save drop-down menu.
  5. Select Save As....
  6. Browse to the folder where you will save the .m file (e.g., C:\Users\username\Documents\MATLAB).
  7. Type STK_Matlab in the File name field.
  8. Ensure Save as type is set to MATLAB Code files (UTF-8) (*.m).
  9. Click Save.

Writing comments in your script

Write comments by preceding the line with the % symbol.

  1. In the MATLAB Editor, type or copy and paste the following comment onto line 1:
  2. %Task1

  3. Press Enter on your keyboard.

Locating STK Object Model and MATLAB code snippets

Code snippets demonstrate tasks that are commonly encountered when working with the STK Object Model.

  1. Return to the STK Programming Help.
  2. Go to Using Core Libraries > STK Object Model > MATLAB Code Snippets.

Creating an STK instance

The AgStkObjectRoot Object is the top-level object in the Object Model hierarchy. The AgStkObjectRoot object provides methods and properties to load scenarios, create new ones, and access the Object Model Unit preferences. From the AgStkObjectRoot object, you can access all other objects and collections exposed by the Object Model.

  1. Locate Initialization under the subheading "How do I ..." on the MATLAB Code Snippets topic page.
  2. Select Start STK and get a reference to IAgStkObjectRoot.
  3. You won't use the exact MATLAB snippets as seen in STK Programming Help. When using snippets to create scripts, you need to edit the code to build your custom scenario. You can compare the edited code in this tutorial to the snippet code in STK Programming Help.

  4. Type or copy and paste the following code to the STK_Matlab.m script onto lines 2 through 4.
  5. % Create an instance of STK

    uiApplication = actxserver('STK12.Application');

    uiApplication.Visible = 1;

  6. Press Enter.
  7. Place your cursor in front of %Task1.
  8. Click Section Break in the MATLAB Toolstrip.
  9. Task 1 Example

  10. Place your cursor before %Task1.
  11. Click Run and Advance in the MATLAB Toolstrip.
  12. Look at the MATLAB Workspace.

    You created a variable called uiApplication and started an instance of STK. You also made the STK splash screen visible.

  13. AGI recommends that you save your MATLAB script after completing each task section.

Using MATLAB IntelliSense and STK Programming Help

The second part of the Start STK and get a reference to IAgStkObjectRoot snippet shows an example of how to expose the STK object root. Manually enter this information in the MATLAB Command Window for familiarization. MATLAB can work with STK using IntelliSense.

Selecting a root of the Application Model

Use IntelliSense to select an application root of the STK Object Model.

  1. Put your cursor in the Command Window.
  2. Type the following: root = uiApplication.; make sure to include the period (.).
  3. Press the Tab key on your keyboard after the period (.). IntelliSense will show you possible selections.
  4. IntelliSense Selections

  5. Return to the STK Programming Help.
  6. Type or paste IAgUiApplication in the search field located in the upper-right corner. Case doesn't matter.
  7. Press Enter.
  8. Select AgUiApplicationLib~IAgUiApplication in the search results. IAgUiApplication represents a root of the Application Model.

Exposing the STK object root

Looking at the IAgUiApplication page, most of what you see in IntelliSense matches the Public Methods and Properties.

  1. Scroll down the IAgUiApplication Interface help topic page to Public Properties.
  2. Select Personality2, which returns a new instance of the root object of the STK Object Model.
  3. You could have searched for any of the IntelliSense selections. Searching for Personality2 would have taken you directly to the help page and its description.

  4. Return to the Command Window.
  5. Press the Tab while the cursor is just after the period (.) of the root = uiApplication. command.
  6. Select Personality2 in IntelliSense.
  7. Press Enter.
  8. Place a semicolon after Personality2.
  9. Press Enter.
  10. Add this whole line (root=uiApplication.Personality2;) to your MATLAB script on line 6.
  11. Look at the MATLAB Workspace. You've exposed the STK object root, so you can start creating a scenario.

Scripting for a new scenario

You will use your MATLAB script to interact with STK. You've launched STK via the MATLAB interface. Now create a new scenario, set the scenario time period, and reset the animation time.

  1. In the STK_Matlab.m script, type or copy and paste the following comment on lines 7 and 8:
  2. %%

    %Task2

  3. Press Enter. This adds a section break and the task identifier at the same time. You will do this for all subsequent tasks.
  4. Return to MATLAB Code Snippets under Using Core Libraries > STK Object Model in the STK Programming Help.
  5. Locate SCENARIO MANAGEMENT (under Scenario) on the MATLAB Code Snippets topic page.
  6. Select Create a new Scenario.
  7. In MATLAB, type or copy and paste the following to the STK_Matlab.m script onto lines 9 and 10.
  8. % IAgStkObjectRoot root: STK Object Model Root

    root.NewScenario('Example_Scenario');

  9. Press Enter.

Using the IAgStkObjectRoot Interface

IAgStkObjectRoot Interface represents the automation interface supported by the root object of the Automation Object Model.

  1. Return to the STK Programming Help.
  2. Type or copy and paste "IAgStkObjectRoot" in the Search field.
  3. Press Enter.
  4. Select STKObjects~IAgStkObjectRoot in the search results.
  5. Select NewScenario in the Public Methods list.

Creating a new scenario

The NewScenario Method creates a new scenario.

  1. There is no syntax specifically for MATLAB, so look at the syntax for [Visual Basic .NET].
  2. Select ScenarioName in the Visual Basic .NET syntax.
  3. Syntax

    The NewScenario method expects a string that is the scenario name. In the line you added to Task 2, you set the scenario name as Example_Scenario.

Set the analysis start and stop times

  1. Return to MATLAB Code Snippets.
  2. Locate SCENARIO MANAGEMENT on the MATLAB Code Snippets topic page.
  3. Select Change scenario time period.
  4. Type or copy and paste the following to the STK_Matlab.m script onto lines 11 and 12.
  5. % IAgStkObjectRoot root: STK Object Model Root

    root.CurrentScenario.SetTimePeriod('Today', 'Tomorrow');

  6. Press Enter.
  7. You are only using the first two lines of code from the snippet. STK automatically sets the scenario epoch time to match your analysis start time.

Resetting the scenario animation time

  1. Return to MATLAB Code Snippets.
  2. Locate SCENARIO MANAGEMENT on the MATLAB Code Snippets topic page.
  3. Select Reset the scenario time.
  4. Type or copy and paste the following to the STK_Matlab.m script onto lines 13 and 14:
  5. % IAgStkObjectRoot root: STK Object Model Root

    root.Rewind;

  6. Press Enter. You are using Rewind Method (IAgAnimation) to stop and reset the animation.
  7. Task 2 Example

  8. Place your cursor in front of %Task2.
  9. Click Run and Advance in the MATLAB Toolstrip.
  10. Looking at STK, a new scenario named Example_Scenario () is open and the time has been reset in the Current Scenario Time field of the Animation toolbar.

Inserting a Target object

To create a new object such as a Target () object, use AgESTKObjectType Enumeration. Not every object in STK has an associated snippet, so you might need to do some editing. Target (), Place (), and Facility () objects contain the same properties. They're seen as different object classes. In this instance, since there isn't a snippet to insert a new Target object into the scenario, use the Facility object code and make some simple changes to the code.

  1. Return to your MATLAB script.
  2. Type or copy and paste the following comments onto lines 15 and 16:
  3. %%

    %Task3

  4. Press Enter.
  5. Return to MATLAB Code Snippets.
  6. Locate FACILITY on the MATLAB Code Snippets topic page.
  7. Select Create a facility (on the current scenario central body).
  8. Type or copy and paste the following to the STK_Matlab.m script onto lines 17 and 18.
  9. % IAgStkObjectRoot root: STK Object Model Root

    target = root.CurrentScenario.Children.New('eTarget', 'MyTarget');

  10. Press Enter.
  11. The snippet code is: facility = root.CurrentScenario.Children.New('eFacility', 'MyFacility');. You are swapping out the variable eFacility for eTarget and changing the name to 'My Target'.

Retrieving the current scenario

The CurrentScenario property returns a Scenario () object or null if no scenario has been loaded yet.

  1. Return to the STK Programming Help.
  2. Enter "CurrentScenario" in the Search field.
  3. Press Enter.
  4. Select STKObjects~IAgStkObjectRoot~CurrentScenario in the search results.
  5. Go to Visual Basic.NET syntax in the CurrentScenario Property (IAgStkObjectRoot) topic page.
  6. Select IAgStkObject.
  7. VB.NET IAgStkObject

Retrieving children of an object

IAgStkObject Interface represents the instance of an STK object. Children Property (IAgStkObject) returns a collection of direct descendants of the current object.

  1. Go to Public Properties on the IAgStkObject Interface topic page.
  2. Select Children.
  3. Go to Visual Basic.NET syntax in the Children Property (IAgStkObject) topic page.
  4. Click IAgStkObjectCollection.

Retrieving a collection of STK objects

IAgStkObjectCollection Interface represents a collection of STK objects.

  1. Go to Public Methods in the IAgStkObjectCollection Interface topic page.
  2. Select New.

Creating an STK object

New Method (IAgStkObjectCollection) creates an STK object using a specified class and instance name.

  1. Go to the Visual Basic.NET syntax on the New Method (IAgStkObjectCollection) topic page.
  2. Click AgESTKObjectType.

AgESTKObjectType Enumeration

The AgESTKObjectType Enumeration topic page shows STK objects (members) with their values and descriptions. When using the AgESTKObjectType Enumeration to insert a new Target () object, you can use the member name eTarget or the value 23. In this case, you are using eTarget and setting the Target object's name to MyTarget. This is another way to use the STK Programming Help. On your own, you might have to take some time working your way through the pages to find what you're looking for.

Placing the Target object

Place the Target object at a specific location.

Assigning the location

Use a MATLAB code snippet to assign the location of the Target.

  1. Return to MATLAB Code Snippets.
  2. Locate FACILITY in the MATLAB Code Snippets page.
  3. Click Set the geodetic position of the facility.
  4. Type or copy and paste the following to the STK_Matlab.m script onto lines 19 through 21.
  5. % IAgTarget Interface provides access to the properties and methods used in defining a target object.

    % Latitude, Longitude, Altitude

    target.Position.AssignGeodetic(50, 100, 0)

  6. Press Enter.
  7. Task 3

  8. In the script, place your cursor in front of %Task3.
  9. Click Run and Advance in the MATLAB Toolstrip.

Checking the location in STK

  1. Bring STK to the front to view MyTarget () in the 2D and 3D Graphics windows.
  2. Right-click MyTarget () in the Object Browser.
  3. Select Properties ().
  4. Note the Latitude, Longitude, and Altitude on the Basic > Position page.
  5. If you have an Internet connection and are using Terrain Server, Altitude will have a value higher than 0 km. That's because you placed the Target object on the surface of the terrain. If you are not using the Terrain Server, the Target object will be on the surface of the WGS84 ellipsoid.

  6. Click Cancel to close MyTarget's properties ().

Inserting a Satellite object

  1. Return to your MATLAB script.
  2. Type or copy and paste the following comments onto lines 22 and 23:
  3. %%

    %Task4

  4. Press Enter.
  5. Return to MATLAB Code Snippets.
  6. Locate SATELLITE in the MATLAB Code Snippets page.
  7. Select Create a satellite (on the current scenario central body).
  8. Return to your MATLAB script.
  9. Type or copy and paste the following to the STK_Matlab.m script onto lines 24 and 25.
  10. % IAgStkObjectRoot root: STK Object Model Root

    satellite = root.CurrentScenario.Children.New('eSatellite', 'MySatellite');

  11. Press Enter.

Learning about Connect

The Connect module provides you with an easy way to connect with STK and work in a client-server environment. You can use the library shipped with Connect to build applications that communicate with STK. This library contains functions, constants, and other messaging capabilities that you can use to connect third-party applications to STK.

  1. Return to the STK Programming Help.
  2. Go to Using Core Libraries > Connect.
  3. This is a great place to learn about Connect. Take some time to become familiar with the links on this page.

Propagating your satellite via Connect

Just like you did while using the STK Object Model and MATLAB Code Snippets, you can use the MATLAB Connect Code Snippets help topic to become familiar with Connect. Use Connect to propagate your Satellite () object.There are several propagators in STK (e.g., Two-Body, J2 Perturbation, J4 Perturbation, SGP4, etc.).

  1. Go to Using Core Libraries > Connect > Connect Code Snippets.
  2. Locate Satellite in the MATLAB Connect Code Snippets topic page.
  3. Select Set initial state of satellite and propagate.
  4. Return to your MATLAB script.
  5. Type or copy and paste the following to the STK_Matlab.m script onto lines 26 and 27.
  6. root.ExecuteCommand('Units_Set * Connect Distance "Kilometers"'); %Default Connect Units are meters

    root.ExecuteCommand('SetState */Satellite/MySatellite Classical TwoBody "UseAnalysisStartTime" "UseAnalysisStopTime" 60 ICRF "UseAnalysisStartTime" 6678.14 0 28 180 0 180');

  7. Press Enter.
  8. This is an instance where the Connect Command has changed but the snippet uses an old command. In the snippets, the code is root.ExecuteCommand('SetUnits / km'). SetUnits is an obsolete command. If you have a set of commands and upgrade to a new version of STK and the command no longer works, go to Deprecated Commands. You will find both deprecated commands and obsolete commands. Locate the bad command and you will find the command that has replaced it.

    • ExecuteCommand Method executes a custom Connect action.
    • Units_Set sets units of measure. You're using Units_Set because Connect's distance unit defaults to meters and you require kilometers.

Setting the Satellite state

Learning about the SetState Connect command

Look at the Alphabetical Listing of Connect Commands to get information on the SetState command.

  1. Return to the STK Programming Help.
  2. Go to Library Reference > Connect Command Library.
  3. Note the links in the Connect Command Listings page.
  4. Select Alphabetical Listing of Connect Commands. The Alphabetical listing includes all Connect commands, regardless of their groupings.
  5. Click "S" at the top of the Alphabetical Listing page.
  6. Locate and select the SetState Classical command.
  7. Scroll through the SetState Classical page and note the following:
    • Syntax will help you understand the input values of your SetState command.
    • The description chart explains each input and its associated unit.
    • In the Examples section, there are several examples that you can copy and edit for your particular scenario.

Using MATLAB to set the Satellite state

  1. Return to your MATLAB script.
  2. Using SetState syntax, set the following values in the SetState Connect command that you entered into your MATLAB script.
  3. OptionValue
    SemiMajorAxis7200
    Eccentricity0
    Inclination90
    ArgOfPerigee0
    RAAN0
    MeanAnom0

    The SetState command in MATLAB should match the following:

    root.ExecuteCommand('SetState */Satellite/MySatellite Classical TwoBody "UseAnalysisStartTime" "UseAnalysisStopTime" 60 ICRF "UseAnalysisStartTime" 7200 0 90 0 0 0');

    Task 4

  4. Place your cursor in front of %Task4.
  5. Click Run and Advance in the MATLAB Toolstrip.
  6. Bring STK to the front to view MySatellite in the 2D and 3D Graphics windows.
  7. Open MySatellite's () properties ().
  8. Note and match the property settings and values to your SetState Connect command.
  9. Click Cancel when finished.

Creating access intervals between MySatellite and MyTarget

Use the STK Object Model to create access intervals from MySatellite () to MyTarget ().

Entering the access commands into MATLAB

Use your MATLAB script to enter access computation commands.

  1. Return to your MATLAB script.
  2. Type or copy and paste the following comments onto lines 28 and 29:
  3. %%

    %Task5

  4. Press Enter.
  5. Return to STK Programming Help.
  6. Go to Using Core Libraries > STK Object Model > MATLAB Code Snippets.
  7. Locate ACCESS on the MATLAB Code Snippets topic page.
  8. Select Compute an access between two STK Objects (using IAgStkObject interface).
  9. Return to your MATLAB script.
  10. Type or copy and paste the following to the STK_Matlab.m file onto lines 30 through 33.
  11. % Get access by STK Object

    access = satellite.GetAccessToObject(target);

    % Compute access

    access.ComputeAccess();

  12. Press Enter.

Computing and checking the access intervals

Run the latest MATLAB commands and check the access calculation results in STK.

    Task 5

  1. In the script, place your cursor in front of %Task5.
  2. Click Run and Advance in the MATLAB Toolstrip.
  3. Bring STK to the front. You can see access lines over Asia in the 2D Graphics window.

Retrieve the access data

You created access intervals between the Satellite () object and the Target () object. An easy way to extract and see those times is to create an interval collection of access start and stop times.

Scripting access interval retrieval in MATLAB

Write a MATLAB script task to get the access interval times from STK.

  1. Return to your MATLAB script.
  2. Type or copy and paste the following comments onto lines 34 and 35:
  3. %%

    %Task6

  4. Press Enter.
  5. Return to MATLAB Code Snippets.
  6. Locate ACCESS in the MATLAB Code Snippets page.
  7. Select Compute and extract access interval times.
  8. Return to your MATLAB script.
  9. Type or copy and paste the following to the STK_Matlab.m script onto lines 36 through 40.
  10. % IAgStkAccess access: Access calculation

    % Get and display the Computed Access Intervals

    intervalCollection = access.ComputedAccessIntervalTimes;

    % Set the intervals to use to the Computed Access Intervals

    computedIntervals = intervalCollection.ToArray(0, -1);

  11. Press Enter.

Retrieving the access interval times

Run Task 6 of your MATLAB script to retrieve the access inteval times.

    Task 6

  1. In the script, place your cursor in front of %Task6.
  2. Click Run and Advance in the MATLAB Toolstrip.
  3. In the MATLAB Workspace, double-click computedIntervals.
  4. When the computedIntervals cell opens, expand column 1 and column 2 so you can read the access data; your data will have different values. Column 1 shows the start times of the accesses and column 2 shows the stop times.
  5. When finished, close the cell.

Investigating data providers

STK generates reports and graphs using selected data providers for the specific report or graph style. You can view data providers, both groups and individual elements, when using the Report & Graph Manager inside of STK. The STK Programming Help contains details of data provider groups, individual elements, and report and graph styles.

  1. Type or copy and paste the following to the STK_Matlab.m script onto lines 41 and 42:
  2. %%

    %Task7

  3. Press Enter.
  4. Return to STK Programming Help.
  5. Go to Library Reference > Data Providers Reference.
  6. In the Data Providers by Object page, you can spend a lot of time looking at an object's data providers, both groups and elements.

Extracting data providers

Your scenario is 24 hours long. The Satellite () object data provider group named "Passes" contains extensive data about the satellite's orbit for each pass. The data provider group "Precision Passes" contains, for specific times, the following:

  • Precision pass number - This number has two parts: the integer pass number for the given time and the fraction of the orbit from the ascending node for that time.
  • Precision path number - This is the satellite's orbit path number, which will remain at the value of 1 until the ground track repeats, at which time the number will increase to 2, and so on..

Use MATLAB to extract these data.

  1. Go to Using Core Libraries > STK Object Model > MATLAB Code Snippets in the STK Programming Help.
  2. Locate DATA PROVIDERS on the MATLAB Code Snippets topic page.
  3. Select Getting Data for a Single Point in Time.
  4. Return to your MATLAB script.
  5. Type or copy and paste the following to the STK_Matlab.m file onto lines 43 through 48
  6. % IAgStkObjectRoot root: STK Object Model root

    % IAgSatellite satellite: Satellite object

    % Change DateFormat dimension to epoch seconds to make the data easier to handle in MATLAB

    root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec');

    satPassDP = satellite.DataProviders.Item('Precision Passes').ExecSingle(2600);

    pass = cell2mat(satPassDP.DataSets.GetDataSetByName('Precision Pass Number').GetValues);

  7. Press Enter.
  8. Task 7

Setting date format and elements

  1. Look at the code from line 46: root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec');
  2. Return to the STK Programming Help.
  3. Go to Using Core Libraries > STK Object Model > STK Util > Dimensions and Units.
  4. Scroll down to DateFormat in the STK Object Model Unit Preferences page.
  5. Your scenario's default date format is Gregorian UTC (UTCG). As stated in the code snippet, changing the DateFormat dimension to epoch seconds to makes the data easier to handle in MATLAB. Since your scenario is 24 hours long, STK expresses the scenario end time as 86400 EpSec. Thus, a scenario UTCG time of 30 Jun 2023 08:11:49.699 will now appear as 15109.699 EpSec. This is easier to read and use in MATLAB.

  6. Look at Available Units. The Epoch Seconds element is EpSec.

Selecting satellite data providers

  1. Return to your MATLAB script.
  2. Look at the code from line 47: satPassDP = satellite.DataProviders.Item('Precision Passes').ExecSingle(2600);
  3. Return to STK Programming Help.
  4. Go to Library Reference > Data Providers Reference.
  5. Select Satellite in the Data Providers by Object page.
  6. Select Precision Passes in the Available Data Providers chart.

Retrieving the Precision Pass data

  1. Return to your MATLAB script.
  2. Look at the code from line 48: pass = cell2mat(satPassDP.DataSets.GetDataSetByName('Precision Pass Number').GetValues);
  3. Place your cursor in front of %Task7.
  4. Click Run and Advance in the MATLAB Toolstrip.
  5. Look at the pass value (e.g., 1.4276) in the MATLAB Workspace.
  6. Precision Pass Value

    The Precision Pass Number of the satellite at the analysis start time (0 epoch seconds) is 1.0000. For the above example, a Precision Passes value of 1.4276 indicates that the Satellite object has orbited the central body almost one-half of an orbit based on the given scenario time of 2600 epoch seconds. With a 24-hour analysis period, any value from 0 through 86400 epoch seconds will work. You can change this value and rerun task 7 to determine precision pass numbers throughout the 24-hour analysis period.

Summary

You began by viewing a small portion of the STK Programming Help pages. Next, using MATLAB code snippets, you performed the following:

  • Created a connection between MATLAB and the STK Application
  • Exposed the STK object root
  • Created a new scenario
  • Inserted and positioned a Target object
  • Inserted and propagated a Satellite object
  • Calculated accesses between the Satellite object and the Target object
  • Extracted access data from STK into MATLAB
  • Used data providers to changes time units from UTCG to EpSec
  • Extracted a satellite precision pass value from STK into MATLAB

On your own

Throughout the tutorial, hyperlinks were provided that pointed to in-depth information concerning the STK Object Model and Connect. Now is a good time to go back through this tutorial and view that information. Obviously, there is a lot to learn. However, this tutorial should have provided some familiarization on how to use STK Programming Help. Explore!

The STK Programming Help provides tutorials designed to help you become more familiar with the STK Object Model and Connect. SeeTutorials, Code Samples, Code Snippets, and Online Resources for additional content.

AGI maintains a GitHub repository of code samples to help you get started with the STK Object Model.