STK Components for .NET 2021 r1

## 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 installSample 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.

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.

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

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

AGI.Foundation.Graphics

AGI.Foundation.Core

Build the Solution.

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

Copy this file to the

*Assemblies*directory of your STK Components install.Close Visual Studio.

Start MATLAB.

Within MATLAB, change directories to the MATLAB directory in your STK Components install:

*Examples\Matlab*Open the LoadComponents.m file in the MATLAB editor.

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

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.

Save the LoadComponents.m file.

Open the RunComponentDemo.m file in the MATLAB Editor.

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.