Click or drag to resize

Using STK Components with Matlab

The Mathworks product MATLAB supports using .NET libraries as an external interface. This means that STK Components can be used from within the MATLAB environment. Help from Mathworks is located on their site here.

This topic will show you how to setup and use STK Components with MATLAB to perform some simple analysis, including how to use Insight3D with MATLAB.

Prerequisites

You must have the following prerequisites met to integrate STK Components with MATLAB:

  • STK Components, Release 2009r3 or later

  • A valid STK Components license

  • Mathwork's MATLAB product, version R2009a or later installed

  • Visual Studio 2005 or later

  • Sample MATLAB files located in the Examples\MATLAB directory of the STK Components install

  • Sample Insight3D C# project used to display the Insight3D globe from within MATLAB, located in the Examples\MATLAB\Insight3DDialogLibrary folder of the STK Components install

Tutorial

This section will show you how to set up MATLAB using STK Components and the sample files provided with the STK Components Install.

Building the Insight3D Dialog Library

Before we start MATLAB and run through the examples, we need to build the Insight3D project that allows us to use the Insight3D globe from within MATLAB.

  1. Open the Insight3DDialogLibrary Visual Studio Solution in the examples folder: Examples\Matlab\Insight3DDialogLibrary

    Note that this project is a class library. It creates a .dll file, with an embedded form that houses the Insight3D component

  2. Ensure the following two STK Components assemblies are referenced from your installation:

    • AGI.Foundation.Graphics

    • AGI.Foundation.Core

  3. Build the Solution.

  4. Locate the .dll file just built in either the Release or Debug directory: Insight3DDialogLibrary.dll.

  5. Copy this file to the Assemblies directory of your STK Components install.

  6. Close Visual Studio.

Configuring the STK Components License

  1. Start MATLAB.

  2. Within MATLAB, change directories to the MATLAB directory in your STK Components install: Examples\Matlab

  3. Open the LoadComponents.m file in the MATLAB editor.

  4. Open your STK Components License file in any text editor (the MATLAB editor will work fine here too).

  5. In the LoadComponents.m file, update the MATLAB string with your license information. Note that the MATLAB string containing your license must be an exact match to the license file you received from AGI, including all XML elements.

  6. Save the LoadComponents.m file.

Running the Demo

  1. Open the RunComponentDemo.m file in the MATLAB Editor.

  2. This file runs all the demos, after first loading the components libraries. You can run this file to execute all the demos at once, or can also step through each file using the Matlab debugger, seeing what each line does.

STK Components MATLAB Example Files
  • RunComponentDemo.m - Loads each file in order, running the entire demo.

  • LoadComponents.m - Loads STK Components into MATLAB, imports all the required namespaces and activates the license. Note that MATLAB currently has no way to allow you to unload a .NET assembly, once loaded. Reloading an assembly that is already loaded may generate a MATLAB warning.

  • InitializeData.m - Initializes data required for the GpsReceiver object in the navigation accuracy example, and initializes the Earth object used in the examples.

  • NavigationExample.m - Example STK Components code that sets up and runs the navigation examples, using the Navigation Accuracy Library. The example calculates Dilution of Precision (DOP), and assessed and predicted navigation accuracy for a single site. If you don't have a license for the Navigation Accuracy Library, simply comment out the NavigationExample line in the RunComponentDemo.m file.

  • DGLExample.m - This file contains example DGL code that creates an SGP4 propagator from a TLE, and a facility. It then calculates access over a three day period from that facility to the satellite using an ElevationAngleConstraint. The access times are then output to the MATLAB Command Window.

  • InitInsight3D.m - There is a specific limitation in the Mathworks .NET handling that prevents a user from being able to include .NET user controls in a MATLAB figure. To circumvent this, we've created a workaround that uses a .NET Library project. This project contains a single form with the Insight3D component embedded in it. The LoadComponents.m file loads this library's DLL on line 9. This .m file then creates the Insight3D window with the Insight3DDialogLibrary class using the defined title and window size.

  • DrawCircles.m - This file shows simple examples of how to interact with the Insight3D globe window. Three concentric circles are drawn around Philadelphia.

  • RemoveCircles.m - This file shows how to remove two of the circles placed on the Insight3D globe in the DrawCircles.m file. This also shows that multiple .m files can interact with the same Insight3D globe.