On this page
You can use MATLAB® to evaluate expressions written in MATLAB syntax in Cameo Simulation Toolkit. You must install MATLAB® first and set up your system to call and use it in Cameo Simulation Toolkit.
Note
- For successful integration, you must use either the 64-bit or 32-bit version of MATLAB (Version 2012a or later) to align it with the 64-bit or 32-bit version of modeling tools, e.g., MagicDraw or Cameo Systems Modeler.
- For Mac users, Cameo Simulation Toolkit version 18.5 SP2 and later can integrate with MATLAB® 2016b seamlessly without disabling System Integrity Protection (SIP) unless it is necessary to disable SIP as a new feature of the latest OS X El Capitan for successful integration.
Warning
MATLAB® 2014a on Mac OS is not capable of evaluating and returning values via Simulation Console, which causes MagicDraw to freeze. To solve this problem, please consider upgrading MATLAB® 2014a to 2014b or later.
Disabling OS X El Capitan's System Integrity Protection (SIP)
To disable OS X El Capitan's System Integrity Protection (SIP)
- Restart your Mac.
- As soon as the screen turns black, hold down the command+R keys to access the Recovery Partition.
- Release the keys once the Apple logo appears on your screen.
- Click the Utilities menu and select Terminal.
- Type
csrutil disable
into the Terminal window and press Return. - The Terminal should display a message that SIP was disabled.
- Restart your Mac for the changes to take effect.
- Run MagicDraw/Cameo System Modeler and integrate it with MATLAB®.
Integrating MagicDraw or Cameo Systems Modeler with MATLAB® (on Microsoft Windows or Mac OS X)
Note
To enable the Integrations menu under the Tools main menu, you must change the perspective to System Engineer or Software Architect by doing the following:
- From the main menu, select Options > Perspectives > Perspectives. The Select Perspective dialog opens.
- Select System Engineer or Software Architect and click Apply. The Integrations menu will be enabled.
To integrate MagicDraw or Cameo Systems Modeler with MATLAB® (on Microsoft Windows or Mac OS X)
From the main menu, click Tools > Integrations. The Integrations dialog opens.
- Select MATLAB® and click Integrate/Remove Integration. The MATLAB® directory selection dialog opens.
- Specify the directory where you installed MATLAB® and click OK.
Note
- If there are problems with integrating MATLAB® on Windows, please ensure that MagicDraw is running with the administrator's privileges, and then try to integrate again.
- When integrating with MATLAB® for the first time or changing the MATLAB® version, restart your machine.
- If the system has been integrated with MATLAB® previously, you do not have to restart the system since system variables have already been updated. Only restart MagicDraw.
You can also integrate MagicDraw or Cameo Systems Modeler with MATLAB® manually using the following steps.
- Using MATLAB on 32-bit and 64-bit Microsoft Windows
- Using MATLAB on Mac OS 10.6 (Snow Leopard)
- Using MATLAB on 32-bit and 64-bit Linux
Connecting to a running MATLAB session
Simulation Toolkit can make connection to a running MATLAB session, thus all variables in the workspace can be used.
To connect Simulation Toolkit to a running MATLAB session through sharing
- Execute the matlab.engine.shareEngine command through the MATLAB Command window.
Note
- MATLAB must be integrated successfully before the connection is made.
- If the sharing command shown above is not executed, the other MATLAB session loaded by Simulation Toolkit will be used instead of the shared one.
After the session connection, Simulation Toolkit can access variables in the MATLAB shared workspace that are not in the SysML model. You can define some variables in MATLAB, e.g., m1 and m2 and solve parametric in Simulation Toolkit. These two groups of variables are then merged and can be accessed in MATLAB as shown in the following figure.