FRED Automation with Matlab

Using FRED’s COM interface it is possible to exchange data with external programs such as MATLAB and Excel.  This article presents an example where FRED and MATLAB are used respectively as the automation client and server in order to exchange data and create plots.  There are a few steps that should be taken both in FRED and MATLAB before executing your script:

In MATLAB:

  1. Start an instance of MATLAB
  2. Execute the command: enableservice(‘AutomationServer’,true)
  3. Execute the command: enableservice(‘AutomationServer’)

In FRED:

  1. Right mouse click in the script editor and choose: Edit > References
  2. Choose the Matlab Type Library
  3. Dimension your Matlab object in the script as type MLApp.MLApp

The above steps will ensure that 1) FRED uses the current instance of MATLAB as the server instead of the command console, and 2) FRED loads the Matlab type library and can recognize and execute the server’s application commands.  In general, it is not necessary to load the Matlab type library in FRED since the Matlab server can be generically defined as an Object.

 

The example enbedded script in the sample file with this article demonstrates how to use some of the following Matlab application commands:

  • PutWorkspaceData: send real-valued data to Matlab
  • PutFullMatrix: send complex-valued data to Matlab
  • GetWorkspaceData: retrieve data from Matlab
  • Execute: issue Matlab commands to the server for execution

 
Download the FRED File: fredToMatlab.frd