Cameo Simulation Toolkit supports Simulink (MATLAB) co-simulation. Simulation executes the entire Simulink model (*.slx) on all steps, if there are any value changes in the input, which is similar to FMI. Simulation works with Simulink models as attached files and Simulink models located in the same directory of the project.

Warning

  • You must successfully integrate MATLAB Version R2016b or later before using Simulink co-simulation. See Integration with MATLAB.
  • The Simulink model must be exported with any version not later than R2019b (e.g., not R2020).
  • The Simulink model must be exported with the Single simulation output option unchecked.
  • Any duplicated Simulink model is not allowed in the project.
  • If there is no input for the In Port, Simulation will skip the evaluation, and a warning message will be printed in the Console panel.

Note

  • Simulink models without input/output Ports are not executed because there is no connectivity, and value change is not propagated to the Block.
  • This type of Simulink integration is for atomic calculations. When any input changes, outputs such as the parametric diagram are calculated, e.g. In1 → Gain5 → Out1. It occurs as one step of Simulation time, the same as FMU.
  • If the simulink file (.slx) is updated or modified, Simulation needs to restart the MATLAB session by calling the kill matlab command in the Simulation console.

To use Simulink co-simulation


  1. Drag a Simulink model into the Block Definition diagram or Internal Block diagram of the project. The Simulink Import Options dialog will be shown as in the figure below. All input/output Ports are selected by default.

    The Simulink Import Options dialog is shown after dragging a Simulink model into the Block Definition diagram or Internal Block diagram of the project.

    Note

    • You can select the Attach file to the project option to attach the model to be displayed in the Containment tree.
    • The model will be shown as «SimulinkBlock» «Block».
    • The Block name will be used as the model name.
    • Input and output Ports of the Block will be exposed as Flow Ports with directions.
  2. Connect those Flow ports through binding Connectors  in the Internal Block diagram.
  3. Run the simulation. When inputs are available for initialization (e.g., passed via binding), «SimulinkBlock» will be run at the first time and on every input change. You can also see animation of Flow Ports and set breakpoints for debugging.

From the figure below, a system is with two Simulink models: GainAdd and Gain5. GainAdd will multiply Port In1 by 10, multiply Port In2 by 2, and add the two results to Port Out1. Gain5 will multiply Port m by 5. Therefore, result will be [(2 * 10) + (2 * 2)] * 5 = 120.

The Simulink co-simulation result from the system which has two Simulink models (GainAdd.slx and Gain5.slx) connected via Flow Ports.