In this article we demonstrate how you can create, query and modify Simulink models in Epsilon programs. While the example in this article demonstrates using EOL to script Simulink models, it's worth stressing that Simulink models are supported throughout Epsilon. Therefore, you can use Epsilon to (cross-)validate, transform (to other models - Simulink or EMF-based -, or to text), compare and merge your Simulink models.
!!! warning The Simulink driver only works with Java 8. This is due to a limitation of the official MATLAB Java API.
The first time you run Eclipse after installing the Simulink driver you will need to point it to the location of your Matlab installation through the Eclipse Preferences→Epsilon→Simulink
dialog. In particular, you need to specify the location of the <matlab-root>/bin/win64
(or /bin/maci64
if you are on Mac OS) directory and Matlab's engine.jar
as shown below. Note that in most cases, if you installed MATLAB in the default location for your operating system, the paths should be automatically detected, and if not you should usually only need to set the MATLAB root directory in your preferences.
engine.jar
was introduced fairly recently).<matlab-root>/bin/win64
is in the system path (in Windows' Environment Variables).<matlab-root>/sys/java/jre/win64/jre
. To configure an alternative JRE, please set the MATLAB_JAVA
environment variable to point to a compatible JRE, and ensure that both your Eclipse and MATLAB are using the same JRE version.empty.slx
)demo.eol
) and add the content below to it:// Create elements var sineWave = new `simulink/Sources/Sine Wave`; var gain = new `simulink/Math Operations/Gain`; var saturation = new `simulink/Discontinuities/Saturation`; var busCreator = new `simulink/Signal Routing/Bus Creator`; var scope = new `simulink/Sinks/Scope`; // Position them on the diagram sineWave.position = "[100 100 130 130]"; gain.position = "[200 100 230 130]"; saturation.position = "[300 100 330 130]"; busCreator.position = "[400 70 410 300]"; scope.position = "[500 175 530 205]"; // Set their properties gain.gain = 2; busCreator.inputs = 3; // Link them sineWave.link(gain); gain.link(saturation); saturation.link(busCreator); gain.linkTo(busCreator, 2); sineWave.linkTo(busCreator, 3); busCreator.link(scope);
empty.slx
) model