Install Connector | Install Connector for New MATLAB Version | Connect to Different Version of MATLAB | Uninstall MATLAB Version | Troubleshooting | Refresh MATLAB Path Technical Notes | Valid STK-MATLAB Configurations

Using a MATLAB Connector to Interface with STK

This topic provides instructions for setting up the interface between MATLAB and STK using a MATLAB connector.

AGI recommends that you use STK's COM interface to integrate STK and MATLAB. Refer to the MATLAB Interface topic to read about the differences between connectors and the COM interface.

Prerequisites

  • A supported version of MATLAB
  • STK 11 or 12
  • STK Integration license (if using STK 12.2 or earlier)
  • STK Premium or Enterprise (if using STK 12.3 or newer)
  • A valid STK-MATLAB configuration; you can find diagrams of valid configurations of MATLAB and STK in the Configuration section of this topic

Supported MATLAB versions

Click the toggle for a specific version of STK to see the supported MATLAB versions and their accompanying STK MATLAB connectors.

MATLAB R2022b does not work with the STK MATLAB 1.0.20 connector. For MATLAB R2022b, use either the 1.0.19 connector or the 1.0.21 connector.

If you want to see a list of supported MATLAB versions, see the version.txt file in the MATLAB Connector install folder.

Installing an STK MATLAB Connector

The STK MATLAB Connector is the interface that enables MATLAB to communicate with STK.

To install the connector:

  1. Browse to the MATLAB_Connectors or MATLAB_Connectors_X64 folder on the STK install media.
  2. Double-click the setup.exe icon and follow the instructions in the dialog box that appears.
  3. If you want to confirm that the installed version of MATLAB can connect to STK:
    1. Start STK.
    2. On the Edit menu, select Preferences...
    3. In the Preferences dialog box, select the MATLAB page.
    4. The connector that you installed should be identified in the Connectable Version field.

Installing a Connector for a new MATLAB version

  1. Before installing a connector for a new MATLAB version, confirm that the new version of MATLAB is supported by STK and that a connector exists for that version.
  2. Run the most recent MATLAB Connector install to ensure that the updated connector is available.
  3. Install the new version of MATLAB.
  4. If you want to confirm that the installed version of MATLAB can connect to STK:
    1. Start STK.
    2. On the Edit menu, select Preferences...
    3. In the Preferences dialog box, select the MATLAB page.
    4. The connector that you installed should be identified in the Connectable Version field.
  5. On the Edit-Preferences MATLAB page, you can only connect to the most recent version of MATLAB that is installed. Refer to the Connecting to a Different Version of MATLAB section of this topic to change the version that you are connected to.

Connecting to a different version of MATLAB

If you have more than one version of MATLAB installed on your computer and you want to connect to a version that is earlier than the most recent version that you installed, take the following steps in MATLAB:

  1. Run “matlab /regserver” in a command prompt window, with administrator privileges. You will need to browse to the bin folder of the version of MATLAB that you want to use. You may need to use the –c option to specify a different MATLAB license file if the administrator is not licensed to run MATLAB.
  2. Confirm that you have the connectors installed for the version of MATLAB that you want to run.
  3. Browse to the MATLAB_Connectors or MATLAB_Connectors_X64 folder on the STK install media.
  4. Double-click the setup.exe iconand follow the instructions in the dialog box that appears.
  5. If you want to confirm that the installed version of MATLAB can connect to STK:
    1. Start STK.
    2. On the Edit menu, select Preferences...
    3. In the Preferences dialog box, select the MATLAB page.
    4. The connector that you installed should be identified in the Connectable Version field.

Uninstalling a MATLAB version

If you uninstall a MATLAB version that was registered as the automation server and you have another version of MATLAB still installed on the computer where STK resides, refer to the Connecting to a Different Version of MATLAB section of this topic.

Troubleshooting the STK MATLAB interface

On the MATLAB page for Edit-Preferences, you don't see an installed version of a MATLAB Connector.

Take the following steps:

MATLAB cannot find AGI MEX or MFiles.

If you alter the MATLAB search path and then save the change, the AGI MEX and MFiles may be removed from the search path. To restore the MATLAB search path to include the AGI MEX and MFiles, run the Connector Refresh utility.

Refresh MATLAB Path tool

The MATLAB file path is automatically configured to find AGI M-files and MEX files. If you need to reset the MATLAB file path, click Refresh MATLAB Path on the MATLAB Preferences page in STK. You can also run the tool by selecting Refresh MATLAB Path (64-bit) from the Start > All Programs > STK Support Tools menu.

Refresh MATLAB Path tool technical notes

The Refresh MATLAB Path tool adds the default MATLAB user area, the location of the AGI MEX files, and location of the AGI M-files to the AGI:defaultuserworkfolder preference. This preference is overwritten each time that you run the tool. If you override the default user area provided by MATLAB, you must set the "AGI:userworkfolder" preference.

The AGI-provided startup.m file is automatically executed each time that MATLAB starts. The startup.m file extracts preferences configured by the Refresh MATLAB Path tool to add the STK MEX file folders and user work folder to the path.

If you use your own startup.m file, you should rename your startup.m file and set the 'AGI:userstartup' preference to point to this renamed file.

After running the Refresh MATLAB Path tool, type 'help startup' at the MATLAB prompt to show the options that are available.

AeroToolbox for MATLAB

The AeroToolbox is part of the STK-MATLAB interface that provides access to STK conversion routines (e.g., position and velocity, orbit elements, and reference frame transformation) and dynamic geometry calculation methods (e.g., vehicle propagators and position converters). You can read about the AeroToolbox inside MATLAB by typing help aerotoolbox. You can read Help topics for all the functions by typing help {functionName}.

Valid STK-MATLAB configurations

The following diagrams illustrate the valid configurations between STK and MATLAB.

STK/STK Engine and MATLAB Engine configurations

STK/STK Engine and MATLAB Desktop configurations