To generate a Simulink model directly from the modeling tool 


  1. Right-click the Block Data:ConnectedTanks and select Tools Export to Simulink. Please see Generating a simulation file for more information. 
  2. Set the options listed below and click OK:
    • Format: XML (.sdl)

    • S-Function or Simscape: Simscape

    • Simscape port libraries: Create new port types

  3. Launch Matlab with Simulink and Simscape extensions. 
  4. In Matlab’s Current Directory navigation bar, search for the file directory where the Simulink/Simscape files (as well as the SysML files) are saved, and set it as the current directory. The Current Folder panel should display the generated files. 




  5. In the Current Folder panel, double-click on the folder named +ConnectedTanksLibrary_create (this sets the current directory to this folder). Type ssc_build in the Command Window and press Enter. This will generate a folder sscprj in the +ConnectedTanksLibrary_create directory as well as a ConnectedTanksLibrary_create_lib.slx file in the directory with the original ConnectedTanks.slx file. Next, once again, search for and go back to the file directory where the Simulink/Simscape files (as well as the SysML files) are saved, and set it as the current directory.



  6. 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.



  7. Go to Simulation > Model Configuration Settings. This allows to select the types of solver and the runtime of the simulation. Select a Start Time of 0, and a Stop Time of 200 (or any other reasonable number of seconds). Change the Max step size to 0.01. Under Solver Options, keep the solver Type to Variable-step (or any other desirable solver that is suitable). Press Apply.




  8. In Model Configuration Settings, select Simscape in the Commonly Used Parameters panel. Change Log simulation data to All. Make sure Limit data points is unchecked. Press Apply. Press OK.



  9. In the ConnectedTanks Simulink window, go to Simulation > Run.
  10. Once the model has compiled, go to the Matlab’s command window and type/enter ssc_explore(simlog) (make sure that either the version of Matlab has the function ssc_explore, or a file ssc_explore.m is in the same directory as ConnectedTanks.slx in the Current Folder panel). A Simscape data logging explorer: Connected Tanks window will open up.



  11. In the Simscape data logging explorer, the ConnectedTanks blocks can be expanded 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, the Data cursor icon needs to be selected and points on the plot need to be chosen (by clicking it).



  12. To change the default value or initial value parameters of the model, double-click the blocks in the ConnectedTanks Simulink model. A window will pop out for block parameters that can be changed. Run through Steps 7 through 10 to run the simulation with (new) block parameters again.