The MatlabInterface is used to establish communications between MATLAB® and FreeFlyer. Data is exchanged between FreeFlyer and MATLAB through a built-in Component Object Model (COM) interface. This connection provides a way for you to use FreeFlyer's precision spacecraft modeling interactively with custom mathematical models in MATLAB.
Common applications include using basic MATLAB functionality to provide first guess utilities for use in FreeFlyer, loading large sets of data, and custom live graphics that enhance visualization and data analysis.
The following Sample Mission Plans (included with your FreeFlyer installation) demonstrate the use of the MatlabInterface object:
FreeFlyer can interface with 64-bit MATLAB version 7.3 or higher. In order for FreeFlyer to communicate with MATLAB, follow these steps:
1.Shut down all versions of FreeFlyer and MATLAB
2.Start MATLAB then select File à Set Path to select the directory where the desired .m files reside (this will ensure that the matlab.ini file contains the correct path information)
3.Save and Close the Set Path dialog
4.Close MATLAB
5.Start FreeFlyer and verify that the MatlabInterface object’s DLLPath property points to the directory containing the desired version of the MATLAB executable and DLLs
Note: A good practice is to place all of your Matlab *.m files in the same location and only set your Matlab path once.
Create and Edit a MatlabInterface Object
To create and access the properties of a MatlabInterface object:
Through the Object Browser:
1.Create a MatlabInterface object in the Object Browser.
2.Enter the DLL Path. For example, in the DLL Path textbox enter C:\Program Files\MATLAB\R2018b\bin\win64. This path refers to where the MATLAB DLLs exists on the user’s computer.
3.Select whether or not the connection is shared. When this property is enabled, the MATLAB application opened by FreeFlyer may be shared with other applications that are interfacing with MATLAB.
Note: The DLL path (i.e. "C:\Program Files\MATLAB\R2018b\bin\win64" or "/usr/local/MATLAB/R2018b/" ) depends on the version and location of the Matlab DLLs. Specifying an empty DLL path ("") will revert to the most recently installed version of Matlab. This works because the PATH environment variable is set to the "bin" directory. If you encounter trouble using an empty DLL path, this may be because the PATH environment variable needs to be set.
Syntax
The Open, Call, and Close commands are used to establish, access, and terminate the API to MATLAB.
Procedure
•Use the Open command to initiate the MATLAB connection.
•Store data in FreeFlyer Arrays, Matrices, Strings, StringArrays, and/or Variables.
oMATLAB and FreeFlyer must refer to the objects by the same names.
oFor an n-element array, FreeFlyer array indices count from 0 and end with n-1, while MATLAB indices count from 1 to n.
•Use the Call command to pass object(s) to MATLAB.
•A MATLAB m-file performs direct operations on the object(s) or passes them to a MATLAB function. The data in the object(s), following MATLAB execution of the file, are passed back to FreeFlyer.