Matlab Samples

Top  Previous  Next

These sample scripts demonstrate demonstrate various ways to use the Matlab interface for the Runtime API. The examples are built using both the C# and Java runtime API interfaces to show how each can be used, and are divided into a C# and a Java directory based on the interface that's used. The steps required to run the sample Matlab scripts are different based on which API interface is used. There are no extra steps required to execute the C# driven samples, whereas the Java driven samples require additional configuration as described below for Windows.

1.Create a new .txt file called "javaclasspath.txt" and enter in the paths to the two .jar files required for the API including the .jar name. As an example, the default paths of these files in FreeFlyer 7.8.1.50021 on Windows are:

a.C:\Users\[USERNAME]\Documents\FreeFlyer\FreeFlyer 7.8.1.50021 (64-Bit)\Runtime API\java\references\freeflyer-runtimeapi-3.0.0.jar

b.C:\Users\[USERNAME]\Documents\FreeFlyer\FreeFlyer 7.8.1.50021 (64-Bit)\Runtime API\java\references\jna-4.1.0.jar

2.Save the text file in the following location: C:\Users\[USERNAME]\AppData\Roaming\MathWorks\MATLAB\[MATLAB VERSION]

3.(Optional) Through the Windows Environment Variables GUI in the System Control Panel, set up a "MATLAB_JAVA" environment variable and point it to the install directory of the desired JRE/JDK.

a.This only needs to be done if the desired java version is different than that installed alongside Matlab.

b.For example, for JDK 1.8u31 (64-Bit), the path is: C:\Program Files\Java\jdk1.8.0_31\jre

 

To confirm that Matlab has been configured correctly, follow the below steps.

1.Open Matlab.

2.Enter "javaclasspath" into the Command window and make sure that the two paths from Step 1 are appended at the end of the list as static paths.

3.Enter "version -java" and make sure that the version report is the one pointed to by the "MATLAB_JAVA" environment variable created in step 3 above.

 

In Linux, the instructions vary slightly as follows.

1.Create a new .txt file called "javaclasspath.txt" and enter in the paths to the two .jar files required for the API including the .jar name. Don't worry about escaping spaces and special characters in the path, as Matlab will interpret the path as a string and escape the paths for you. If you manually escape the spaces the path will be invalid. As an example, the default paths for these files in FreeFlyer 7.8.1.50021 on Linux are:

a./home/freeflyer/FreeFlyer/FreeFlyer 7.8.1.50021 (64-Bit)/Runtime API/java/references/freeflyer-runtimeapi-3.0.0.jar

b./home/freeflyer/FreeFlyer/FreeFlyer 7.8.1.50021 (64-Bit)/Runtime API/java/references/jna-4.1.0.jar

2.Save the text file in the following location: /[HOME DIRECTORY]/.matlab/[MATLAB VERSION]/

 

To confirm that Matlab has been configured correctly, follow the below steps.

1.Open Matlab.

2.Enter "javaclasspath" into the Command window and make sure that the two paths from step 1 above are appended at the end of the list as static paths.

 

Note: The scripts utilizing the Java runtime API interface require special Matlab configuration steps to import the runtime API archives.

 

Jump to an application description using the following table:

 

Example

Propagate a State Using FreeFlyer

 

 

Propagate a State Using FreeFlyer

This script uses a custom Matlab function to propagate an input state and generate state vectors for a user-defined duration and then plots the resulting trajectory. The runtime API is used within the Matlab function (PropagateState.m) to use FreeFlyer as the propagation engine to generate the state vector data. The runtime API is also used within a separate Matlab function (GetEpochCalendarFormat.m) to generate a calendar-formatted epoch with a user-specified format.

 

 

Output from the Propagate State Example

Output from the Propagate State Example

 

 

For more information on the topics covered by this example, see the Using the Runtime API guide.