Defining Commands

You can define command-type actions to invoke desired functions within MATLAB®. You can enter commands directly or load commands from a MATLAB M-Script file.

The MATLAB adapter automatically sets the current directory in the MATLAB session to the working directory for the adapter. If you want to set the current directory to another directory, you need to provide an explicit cd command in your set of MATLAB commands. In addition, a variable called ESI_MATLAB_rundir is automatically set in the MATLAB session to allow you to refer to the working directory of the adapter, if necessary.

Do not define any commands that begin by deleting all the MATLAB variables from the current workspace, or you will lose all data sent to MATLAB by the adapter. In addition, the MATLAB interface is implemented by a Java object in the current workspace; if you delete all the MATLAB variables, you will lose this object and break the interface.

Important: Because the MATLAB adapter explicitly uses the cd command, any command or M-Script used in the MATLAB session must not define a variable with the name “cd” because this may override the command and would lead to errors.

See Also
Adding Actions
  1. From the Applications section of the action bar, click MATLAB and drop it on the process diagram.
  2. Double-click MATLAB .
    The MATLAB Editor appears.
  3. From the MATLAB Editor, click the Contents tab.
  4. Select the desired mapping-type action from the Initialize, Execution, or Finalize subtabs.

    An area for defining the Command appears on the right side of the editor.

    You can edit the name used to identify the Command action in the Command text box.

  5. Enter commands in the Enter MATLAB commands below or upload an M-Script file text area on the right side of the editor. You can enter the commands directly in the text area or load the commands from an existing MATLAB M-Script file.

    Important: You must check for syntactical errors in the given commands. Optimization Process Composer does not check for proper syntax before execution.

    1. Click Open, and locate the file that you want to load.
    2. All the M-Scripts are stored in the adapter.

    3. Click Open to load the file and to return to the MATLAB Editor.
  6. Click Ok to save your changes and to close the MATLAB Editor.