Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Simulink Basics

Simulink is a graphical tool used in MATLAB for modeling and simulation of control systems.
You can simulate a control system with different inputs and obtain the respective outputs. You can
simulate linear control systems as well as non-linear control systems. In addition, you may apply
for systems where initial conditions are non-zero where we assumed them to be zero in many cases.
To use Simulink, you can do the following steps.

1. Start MATLAB.
2. Press “New” in the “Home” menu and click Simulink Model as shown in Fig 1.

Fig 1: Simulink Model and Simulink Library

3. Then, a blank window will appear as shown in Fig 2.0. Save it as “block1”.

Fig 2: Blank Window

1
4. Press Simulink Library and a new window will appear. (Refer Fig. 1.)
5. In the Simulink Library Browser, select “Sources” in the new window. (Refer Fig. 1.)
6. From “Sources”, you can select the input. For this work, you can select a step input.
(Refer Fig. 3.)

Fig 3 : step input


7. You can change the default parameters by double clicking “step” icon. The parameters,
meaning, their default values and test values expected from you are given in Table 01.
Try changing the default value for “Test No” 01.

Table 01: Parameters of “step” icon


Parameter Meaning Default Test value
Test No 01 02 03 04
Step time Time required to change the step 1 0 0 1 1
Initial value Initial value before the step time 0 0 0 0 0
Final value Value after the step time 1 1 2 2 2
Sample time Sample time used in the simulation 0 0 0 0.1 5

2
8. Drag the “step” icon into the block1 window.
9. In the Simulink Library Browser, select “Continuous” in the new window. By selecting
“Continuous”, you can select a continuous function in the s-domain. For this work, you
can select “Transfer Fcn” icon. (Refer Fig. 4.)
10. The default transfer function in this case is 1/(𝑠 + 1).
11. Drag the “Transfer Fcn” icon into the block1 window. You can change the default
parameters by double clicking “Transfer Fcn” icon. In this case, let’s keep the default
function.

Fig. 4: “Transfer Fcn” icon in “Continuous”


12. In the Simulink Library Browser, select “Sinks” in the new window. (Refer Fig. 5.)
13. From “Sinks”, you can select the put. For this work, you can select “Scope”.
(Refer Fig. 5.)
14. By selecting “scope”, you can visualize the output of the simulation results..
15. Once you placed all 3 components in Simulink model, it will appear as shown in Fig.6.
16. Now you need to connect these components that you can simply do using the mouse by
clicking the endpoint of “Step” with the starting point of “Transfer Fcn”. You can do the
same between “Transfer Fcn” and “Scope”. Once completed your Simulink Model will
appear as shown in Fig. 7.
17. You can use the run button as shown in Fig. 6. to simulate it.

3
18. To see the output result, you can double click the scope.

Fig 5: Selecting “Scope” in “Sinks”

Fig. 6: Simulink model with 3 components

Fig. 7: Components after connecting them

19. For the “Test No” 01 given in table 01, you will get the output view that can adjusted by
clicking the “Autoscale” button (Refer Fig. 8(a) and Fig. 8(b).
20. You can get the same results by replacing the source block “Step” by the “Constant” block
in the Simulink library since time required to change the step is given as 0 (Refer Fig. 9).
“Constant” block can give only a constant value as an input, but cannot change the value
as a step change as in “Step” block during run time.

4
Fig. 8(a): view before auto scaling Fig. 8(b): view after auto scaling

Fig 9: The “Constant” block

21. You can give different inputs by changing the settings values of “Step” block. Try using
the values given in Table 01 and simulate the results.
22. To change the transfer function, you can edit the “Transfer Fcn” block. When you double
click it, you can see the current view. For the numerator the default value is [1] which refers
to “1” and for the denominator is [1 1] which refers to “s+1”. This is similar to giving
polynomial’s coefficients in the command prompt in MATLAB.

5
23. For example, if you want to give the transfer function
𝑠+2
𝑇(𝑠) =
2𝑠 + 3𝑠 + 5

You can give the coefficients by editing the “Transfer Fcn” block as shown in Fig. 10.

Fig 10: Settings of “Transfer Fcn” block

24. When you change the values and return the block, it will appear in the window as shown
in Fig.11.

Fig. 11: Transfer function view in Simulink model

6
25. Close the “Scope” block and run Simulink. When you open the “Scope” block with auto
scale, it will appear as shown in Fig. 12.

Fig 12: Output with oscillatory response


26. Save your project and then save it as “block2”.
27. Remove the “Scope” block. Add a “Clock” block (from “Sources”) and a “XY Graph”
black (from “Sinks”).
28. Connect these blocks as shown in Fig. 13.

Fig 13: Block arrangement in “block2” of the Simulink model

29. Change the parameters of “XY graph as shown in Fig. 14.

30. Now run the Simulink and it should appear as shown in Fig. 15. Compare your output
results using “Scope” and “XY Graph”. In using “Scope”, X axis is always the time axis,
but using “XY Graph”, you can plot the graph of the outputs of any two blocks.

7
Fig 14: Setting XY parameters to suit the output result

Fig 15: The Simulink output for “block2”.

You might also like