Matlab Plug-In Features

The Matlab Plug-In has two main features:

Mapping Matlab Variables to ModelCenter Variables

Variables are created in the Matlab Plug-In by selecting the <click to add variable...> text in the ModelCenter Variables pane. Upon selection, the plug-in will prompt the user to enter variable information.

After creating a variable, property fields will be enabled.

Variable Properties

Properties for each variable can be customized. Note that the type of a variable determines which properties are available for editing. Property values are optional with the exception of the Matlab Name value which must be specified for each variable.

  • Type - Both the type and state may be specified for a variable. Note that the ModelCenter and the Matlab Plug-In currently do not support variables of type "single". Instead, a ModelCenter "double" can be used to represent a Matlab "single". The table below shows type mapping between Matlab variables and ModelCenter variables. The variable state can either be input or output.
    Matlab syntax Matlab type ModelCenter type
    A = 1 1*1 array double
    A = [1 2] 1*2 array double[]
    A = [1 2; 3 4] 2*2 array double[]
    A = 1 1*1 array int
    A = [1 2] 1*2 array int[]
    A = true 1*1 array Boolean
    A = [true false] 1*2 array Boolean[]
    A = 'abc' string array string
    A = {'a', 'ab', 'abc'} cell array string[]
    Note: The new ModelCenter Component Plug-In framework cannot support "structure" types in the Matlab Plug-In. However, it is possible to create a similar function by enumerating every single property / element of the structure in the plug-in as a separate variable or separate array element (if same variable type). See the Structure Examples page.
  • Units - Units for the variable.
  • Description - Short description of the variable.
  • Lower Bound - Numeric lower bound value.
  • Upper Bound - Numeric upper bound value.
  • Enum Values - A comma separated list of acceptable values.
  • Enum Aliases - A comma separate list of strings that can be used in place of the enum values. The number of enum aliases, if specified, must be equal to the number of enum values.
  • Format - The format ModelCenter should use to display the variable.
  • Matlab Name - The name of the corresponding variable in Matlab.

Editing Variables Textually

To edit the variables in a text view, press Edit Variable.... This will launch the Variables Text Editor dialog which can be used to quickly edit a set of variables.

Managing the Matlab Session

The Matlab Plug-In Options dialog allows you to customize the behavior of your plug-in.

Options

  • Use multidimensional arrays - If checked, Matlab matrices are stored as two-dimensional arrays. If unchecked, ranges are stored as one-dimensional arrays.
    • Treat nx1 and 1xn Matlab arrays as 1-dimensional ModelCenter arrays - If checked, Matlab matrices consisting of one row or column are treated as a one-dimensional array. If unchecked, the arrays are sized as 1xN or Nx1.
  • Capture Matlab output as a string variable - If checked, a log of responses from Matlab is stored as a string variable. This is useful for debugging errors in a Matlab m-file.
  • Automatically show Matlab when it starts - If selected, the Matlab session will be made visible automatically each time Matlab is first started by ModelCenter. Note that Matlab is not started until it is needed, i.e., when the Component is run or the plug-in is displayed.
  • Clear Matlab workspace after each run - If checked, causes the plug-in to issue the "clear all" command in between runs.
  • Enable application pool - If checked, enables the user to specify a maximum number of Matlab instances that can be started and run in parallel by the plug-in. A value of -1 in the Maximum number of Matlab instance field means there is no limit to the number of instances that can be started.
    • If an instance of the plug-in has the application pool option disabled and it needs a Matlab instance, it will start and use its own instance without any sharing.
    • If an instance of the plug-in has the application pool enabled and it needs a Matlab instance, it will:
      1. Start a new Matlab instance if the number of instances in the application pool is less than the maximum number
      2. Get an existing unused Matlab instance from the application pool if the number of instances in the application pool is >= the maximum number
      3. Error if the application pool size is at the maximum and all the instances are in use.
  • Specify version of MatLab - If checked, allows the user to specify which installed version of MatLab to use.