This page describes how to simulate the Hydraulics example model in SimulinkLearn more about Hydraulics sample model >>

You can find the Hydraulics sample model in:

  • the modeling tool: Welcome window > Samples > Simulink and Modelica Transformation > Hydraulics .
  • the Installation directory: <modeling tool installation directory>\samples\SysML\Simulink and Modelica Transformation\Hydraulics.


To simulate the Hydraulics model


  1. Export the ConnectedTanks Block to Simulink file. How to >>
  2. In the Simulink Export Options dialog select the following options:
    • Format: XML (.slx)

    • S-Function or Simscape: Simscape

    • Simscape port libraries: Create new port types
    • Composite Signals: Bus Creators/Selectors
  3. Make sure the MATLAB tool is installed.
  4. Double-click the MATLAB icon to start it.
  5. In the file directory select the location of your exported Hydraulics model Simulink files and choose the +ConnectedTanksLibrary folder. The simscape files (.ssc) are displayed in the Current Folder panel. 
    ssc_build
  6. In the Command Window type ssc_build (or sscbuild depending on the Matlab version) and press Enter. This generates a folder sscprj in the +ConnectedTanksLibrary directory as well as a ConnectedTanksLibrary_lib.slx file in the directory with the original ConnectedTanks.slx file.
  7. Go back to the file directory, select the Hydraulics package with exported Simulink files and in the Current Folder select the ConnectedTanks.slx.
  8. In the Current Folder panel, double-click on ConnectedTanks.slx to open the Simulink/Simscape model. Rearrange the blocks to get a better picture of the blocks and links.
  9. On the SIMULATION tab, click the arrow on the PREPARE area and select the Model Settings.

  10. In the Configuration Parameters dialog, on the left side of the dialog:
    a. Select a  Solver property group and specify the following on the right side of the dialog:
      - In the the Simulation time group, change Start time to 0.0Stop time to 200 (or any other reasonable number of seconds).
      - In the Solver selection group, select Type Variable-step or any other desirable solver that is suitable.
      - Click the arrow of the Solver details group and change the Max step size to 0.01.
    b. Select Simscape property group and specify the following on the right side of the dialog:
      - In the Data Logging group, change Log simulation data to All.
      - Make sure Limit data points is unchecked.
  11. Press Apply > OK.
  12. In the ConnectedTanks Simulink window, click .
  13. On the main toolbar, click  to open a Simscape Results Explorer: ConnectedTanks window where you can expand the  ConnectedTanks blocks to see how their properties simulated through time. For the tanks fluidReservoir1 and fluidReservoir2, the properties fluidLevel can be selected to see how the fluid reacted transferred from one tank to the other in the simulation. To see the simulation’s specific data points, select the mouse pointer on the plot.
  14. To change the default value or initial value parameters of the model, double-click the blocks in the ConnectedTanks Simulink model. A Block Parameters dialog opens where you can change parameters. Repeat steps from 5 to 12 to run the simulation with (new) block parameters.