Section 6.12 Use of simulink with control


Simulink is a powerful tool within the MATLAB suite for modelling and simulating system behaviour, especially where the interconnections are complicated and/or there are non-linear components. Being a visual environment, it is straightforward to see how different components relate to each other and thus to construct models representing complex systems.

It is  not the purpose of this section to give an introductory or detailed tutorial to simulink which are available on 'onramp'. Rather the purpose here is to give examples of focused case studies which illustrate some simple scenarios that are directly relevant to a modelling, dynamics and control undergraduate course. It is hoped that, for someone already competent in the use of MATLAB, these simple examples will be enough for students to make progress with any basic requirements.

In the long term we aim to add these files to the control101 toolbox, but for now the draft versions are available separately in the following folder.

A. Introductory examples

The livescript intro_to_simulink_for_system_behaviour.mlx  is a brief introduction to the use of simulink to model systems with some simple components. More importantly, it shows how integration with MATLAB code can make running the simulink file very efficient to allow systematic investigations for a range of parameter values. In essence:

This livescript file makes use of the following paired files which can be accessed through the livescript with supporting explanation or separately if desired. In summary, you can simply run the script file to run the simulation (assuming all files are visible on your MATLAB path).

B. Heating system example

Heating systems are common examples in control courses and indeed there are examples of this  already in the toolbox (e.g. see section 6.8). The purpose of this illustration heating_system_simulink_control101.mlx is simply to show how using simulink allows the easy inclusion of non-linear, or other, components which are not so simple to enter into MATLAB code. The code here introduces two forms of non-linearity, that is delay and dead-zones when switching sign. For simplicity and illustration, all 3 scenarios are within the same simulink file and simulink simply handles these as parallel but independent simulations. The results are collected together into a single scope for comparison.

This example has all the numerical parameters predefined within the simulink model and thus no supporting script file is needed to provide any numerical values.


C. Hydraulic system example

Systems of tanks are also common in control courses and in the toolbox (e.g. see section 6.8), but again, simulink offers the opportunity to consider different arrangements of tanks and to manage the interconnections without having to manipulate into a single large state-space model for simulation in MATLAB, as well as the chance to add non-linear components ass required. The resource  hydraulic_system_simulink_control101.mlx focuses on comparing parallel and series arrangements of tanks (separate simulink file for each arrangement). The required parameter values definition, simulation and plotting is handled within the code sections of the livescript.

The simulink files are:

D. Car suspension example

The livescript car_suspension_simulink_control101.mlx introduces a car suspension scenario where the car drives over a ramp in the road at different speeds. The livescript gives a concise overview of the modelling and scenario and shows the associated simulink diagram to capture this scenario. It also illustrates common sources and sinks that can be used for importing and exporting data, both visually and into the MATLAB workspace. Specifically, here the source allows for non-simple input signals (e.g. not a constant) which are needed to capture the road profile. It also shows how deviation variables can be defined  within the model and corrected to absolute values for plotting.  All the simulation variables and model data are defined within a script for convenience as illustrated in the sections of the livescript.

The simulink file is:


E. Position system example

The livescript file position_system_simulink_control101.mlx is a brief introduction to the use of simulink to model and simulate a simple position system which uses a DC motor to move a lever. More importantly, it shows how integration with MATLAB code can make running the simulink file very efficient to allow systematic investigations for a range of parameter values and specifically in this case, the impact of the inclusion of non-linear components which are harder to handle in simple MATLAB code. This livescript file defines the required parameters and runs the simulations within sections. Users can edit the code in the sections to modify the parameters and other choices. It makes use of the following 3 simulink files:

F. Submersible example

The livescript file submersible_simulink_control101.mlx is a brief introduction to the use of simulink to model and simulate a simple autonomous underwater vehicle.  Here the modelling equations take a form that might lend itself to a standard state-space model, apart from the fact there are some non-linear elements. Simulink allows a simple and transparent implementation of the state dependencies with these nonlinear components, using transfer function blocks and lines as shown in the two simulink files: