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.
- 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.
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.
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.
csrutil disableinto 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®.
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.
- If there are problems with integrating MATLAB® on Windows, run MagicDraw as an Administrator, 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.
To use MATLAB® on a 32-bit or a 64-bit version of Microsoft Windows
- Install MATLAB®.
- Press Windows + R to open the Run dialog.
- Type cmd in the open combo box and click OK to open the command prompt window.
Type "matlab /regserver" and press Enter to register the MATLAB® components to Windows. The MATLAB® command prompt opens and is ready to use.
- Add the path of the MATLAB® bin and bin/win32 (or bin/win64 for Microsoft Windows 64-bit) folders to the Path environment variable using the following steps
5.1 Double-click System in Control Panel to open the System Properties dialog. Click the Advanced tab.
5.2 Click Environment Variables. The Environment Variables dialog opens.
5.3 From the System variables list, select Path and click Edit. The Edit System Variable dialog opens.
5.4 In the Variable value box, enter the path to the MATLAB® bin and bin/win32 folders (or bin/win64 for Microsoft Windows 64-bit version), for example, ;C:\Program Files\MATLAB\R2010b\bin;C:\Program Files\MATLAB\R2010b\bin\win32;.
5.5 In the Variable value box, enter the path to the MATLAB® runtime/win32 (or runtime/win64 for Microsoft Windows 64-bit version), for example, ;C:\Program Files\MATLAB\R2010b\runtime\win32;.
You can skip Step 5.5 in the above procedure if the MATLAB® runtime directory does not exist, since this directory only existed in earlier versions of MATLAB® and not in the newer versions. The MATLAB® runtime is not required in these cases.
5.6 Click OK.
- Restart Windows.
To use MATLAB® on Mac OS 10.6 (Snow Leopard)
- Install MATLAB®.
- Type the following commands in the terminal to show all files in Finder
• $ defaults write com.apple.finder AppleShowAllFiles TRUE
• $ killall Finder
Add the DYLD_LIBRARY_PATH variable to Mac OS:
3.1 Create an empty text file in the /etc folder and name it: launchd.conf.
3.2 Open it with a text editor, for example, TextEdit, and type the following text (no space)
setenv DYLD_LIBRARY_PATH /Applications/MATLAB_R2010b.app/bin/maci64:
3.3 Save the text file as launchd.conf to the desktop.
3.4 Move the launchd.conf file to the /etc folder.
- Create a link to the MATLAB® executable file in /usr/bin if it does not yet exist.
- Call the following commands in the terminal
• $ cd /usr/bin
• $ ln -s /Applications/MATLAB_R2010b.app/bin/matlab matlab
- Type the following commands in the terminal to reset Finder
• $ defaults write com.apple.finder AppleShowAllFiles FALSE
• $ killall Finder
- Restart Mac OS.
You can also use MATLAB® if you are using MagicDraw 18.0 on either Mac OS X 10.10 Yosemite or Mac OS X 10.11 El Capitan, by using the following steps.
- Disable the SIP (if your Mac is OS X El Capitan) by following the instruction to disable OS X El Capitan's System Integrity Protection (SIP).
- Install MATLAB®.
Create the file com.nomagic.magicdraw.simulation.mathengine.plist.
3.1 Create a text file and type the following text.
3.2 Change the /Applications/MATLAB_R2012a.app to your MATLAB directory.
3.3 Save the text file. (If you are using TextEdit, change the file to plain text by clicking Format > Make Plain Text).
3.4 Rename it as com.nomagic.magicdraw.simulation.mathengine.plist.
(Note: If you already have the file com.nomagic.magicdraw.simulation.mathengine.plist in /Library/LaunchAgents, add :/Applications/MATLAB_R2012a.app/bin/maci64:/Applications/MATLAB_R2012a.app/runtime/maci64 to your DYLD_LIBRARY_PATH in your com.nomagic.magicdraw.simulation.mathengine.plist. For example, launchctl setenv DYLD_LIBRARY_PATH <Other_Path>:/Applications/MATLAB_R2012a.app/bin/maci64:/Applications/MATLAB_R2012a.app/runtime/maci64.)
Create the file com.nomagic.magicdraw.simulation.mathengine.matlab.plist.
4.1 Create a text file and type the following text.
4.2 Change "/Applications/MATLAB_R2012a.app" to your MATLAB directory.
4.3 Save the text file. (If you are using TextEdit, change the file to plain text by clicking Format > Make Plain Text).
4.4 Rename it as com.nomagic.magicdraw.simulation.mathengine.matlab.plist.
- Move the files to /Library/LaunchAgents/ by using the Terminal.
5.1 Run the Terminal.
5.2 Go to the plist files directory.
- $ cd [your plist file directory]
5.3 Move the plist file to /Library/LaunchAgents/ using the following command
- $ sudo mv com.nomagic.magicdraw.simulation.mathengine.plist /Library/LaunchAgents/
- $ sudo mv com.nomagic.magicdraw.simulation.mathengine.matlab.plist /Library/LaunchAgents/
6. Create a link to the MATLAB® executable file in /usr/bin if it does not exist, by using the following command in the Terminal
- $ cd /usr/bin
- $ sudo ln -s /Applications/MATLAB_R2012a.app/bin/matlab matlab
You need to change the /Applications/MATLAB_R2012a.app in the command line to your MATLAB directory.
7. Restart Mac OS.
To use MATLAB® on 32-bit and 64-bit (tested with Ubuntu) versions of Linux
- Install MATLAB® (Assume that your MATLAB installation directory is /home/username/ MATHWORKS_R2011A).
- Make sure that C Shell has already been installed on your Linux. To install C Shell on Ubuntu, type the following command in the terminal
• ~$ sudo apt-get install csh
- Create a link to the MATLAB® executable file in /usr/bin if it does not exist, and type the following commands in the terminal
• ~$ sudo -i
• ~$ cd /usr/bin
• ~$ ln -s /home/username/MATHWORKS_R2011A/bin/matlab matlab
- Use a text editor to open the magicdraw file in the bin folder in the MagicDraw installation directory. Type the following text under the line that contains cd"$APP_HOME" to add the MATLAB® bin folder to LD_LIBRARY_PATH of Java and save the magicdraw file.
- on Linux 32-bit, type: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/username/MATHWORKS_R2011A/bin/glnx86:/home/username/MATHWORKS_R2011A/sys/os/glnx86
- on Linux 64-bit, type: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/username/MATHWORKS_R2011A/bin/glnxa64:/home/username/MATHWORKS_R2011A/sys/os/glnxa64
LD_LIBRARY_PATH added to the MagicDraw file.
If there are problems with integrating MATLAB® on Windows, run MagicDraw as an Administrator, and then try to integrate again.