Matlab / Simulink Connection

Navigation:  Installation >

Matlab / Simulink Connection

Previous pageReturn to chapter overviewNext page

In 20-sim you can exchange data with Matlab / Simulink  in various ways:

Export models as m-files
Export models as dll-files
Export a variable to Matlab
Export a parameter to Matlab
Pass a variable value to Matlab every simulation step
Load a variable value from Matlab every simulation step
Pass a command line string to Matlab every simulation step
Export linear systems to Matlab
Import Linear Systems from Matlab

Troubleshooting

If this fails check if the following three points have been fulfilled.

1. Have the correct version of 20-sim and Matlab

To make a connection with Matlab, make sure you have 20-sim 4.1.3.8 or higher installed and a recent version of Matlab (2007 or above).

64-bit versions of Matlab are supported starting with 20-sim 4.6.

 

2. Check if it works

To make the connection to Matlab, Matlab needs to be registered as a COM-component. Not all Matlab versions register the COM-component automatically.

 

1.In 20-sim, open the Simulator (Ctrl+R)
2.Open the Tools menu
3.Click the Matlab button

 

If Matlab starts (be patient this could take some time), the Matlab COM automation server is registered properly and you are finished. In case the error message "Could not start Matlab. Make sure that Matlab is installed and that the Matlab COM automation server is enabled.", proceed with step 3 and 4.

 

3. Enable the Matlab COM automation server

To make the connection to Matlab, Matlab needs to be registered as a COM-component. This can be done in the following manner from the command line (run: cmd):

 

matlab  /regserver

 

The COM-registration only, is not enough for 20-sim to find the DLL's of Matlab. The next step (setting the PATH variable) must be performed also

4. Matlab registration in PATH

The standard registration of Matlab in the PATH is the following (assuming Matlab is installed in Program Files and the used version of Matlab is R2015b):

 

C:\Program Files\MATLAB\R2015b\bin

 

The following path should be added too in case of a 32-bit version of Matlab:

 

C:\Program Files\MATLAB\R2015b\bin\win32

 

In this additional path some important DLL's are present that are necessary to make the connection. for example: libeng.dll. Please check if this DLL is present at this path. If not try to find this DLL in your Matlab installation and add the found path to the PATH environment.

 

Changing the PATH environment variable can be done in the following manner:

 

1.From "My Computer", right mouse button: Properties:
2.On Windows: choose Advanced Properties and go further as Admin
3.Choose the tab: Advanced
4.Choose: Environment Variables.