Post on 03-Jun-2018
8/12/2019 Lab01 Simulink Tutorial
1/23
Getting started with Simulink
An introductory tutorial
Wireless LANsDepartment of Telecommunication Systems and Networks
Technological Education Institute of Messolonghi
F. Plessas 2012
8/12/2019 Lab01 Simulink Tutorial
2/23
Launch Matlab
Start All Programs Matlab 7.0
8/12/2019 Lab01 Simulink Tutorial
3/23
Launch Simulink (1/2)
In theMATLAB
window,
at the >>prompt, type
simulinkand pressEnter
8/12/2019 Lab01 Simulink Tutorial
4/23
Launch Simulink (2/2)
8/12/2019 Lab01 Simulink Tutorial
5/23
Create a new model
Click the new-modelicon in the upper leftcorner to start a new
mu n e Select the Simulink
icon to obtain
elements of themodel
8/12/2019 Lab01 Simulink Tutorial
6/23
Your workspace
Library of elements Model is created in this window
8/12/2019 Lab01 Simulink Tutorial
7/23
Save your model
You might create a new folder, like the oneshown below, called simulink_files
Use the .mdl suffix when savin
8/12/2019 Lab01 Simulink Tutorial
8/23
Example 1: a simple model
Build a Simulink model that solves thedifferential equation
=&
Initial condition x(0) = -1.
First, sketch a simulation diagram of
this mathematical model (equation)
8/12/2019 Lab01 Simulink Tutorial
9/23
Simulation diagram
Input is the forcing function 3sin(2t) Output is the solution of the differential
e uation x t 1)0( =x
Now build this model in Simulink
xx&
s
13sin(2t)
(input)
x(t)
(output)
integrator
8/12/2019 Lab01 Simulink Tutorial
10/23
Select an input block
Drag a Sine Waveblockfrom the Sourceslibraryto the model window
8/12/2019 Lab01 Simulink Tutorial
11/23
Select an operator block
Drag an Integratorblockfrom the Continuouslibraryto the model window
8/12/2019 Lab01 Simulink Tutorial
12/23
Select an output block
Drag a Scopeblock from theSinkslibrary to the model
8/12/2019 Lab01 Simulink Tutorial
13/23
Connect blocks with signals
Place your cursor onthe output port (>) ofthe Sine Waveblock
Drag from the SineWaveoutput to theIntegratorinput
Drag from theIntegratoroutput tothe Scopeinput Arrows indicate the
direction of the signal flow.
8/12/2019 Lab01 Simulink Tutorial
14/23
Select simulation parameters
Double-click onthe Sine Waveblock to set
amplitude = 3and freq = 2.
This produces thedesired input of3sin(2t)
8/12/2019 Lab01 Simulink Tutorial
15/23
Select simulation parameters
Double-click onthe Integrator
initial condition= -1.
This sets our ICx(0) = -1.
8/12/2019 Lab01 Simulink Tutorial
16/23
Select simulation parameters
Double-click onthe Scopeto view
results
8/12/2019 Lab01 Simulink Tutorial
17/23
Run the simulation
In the modelwindow, from the
-
down menu,select Start
View the outputx(t) in the Scope
window.
8/12/2019 Lab01 Simulink Tutorial
18/23
Simulation results
To verify that this plotrepresents the solution tothe problem, solve the
.
The analytical result,
x(t)=1/2 (3/2)cos(2t)
matches the plot (thesimulation result) exactly.
8/12/2019 Lab01 Simulink Tutorial
19/23
Example 2
Constructing and simulating a simple circuitmodel:
8/12/2019 Lab01 Simulink Tutorial
20/23
Create the simulation diagram
8/12/2019 Lab01 Simulink Tutorial
21/23
Constructing and simulating asimple circuit model
8/12/2019 Lab01 Simulink Tutorial
22/23
Notes
Simulink blocks have zero, one or more inputs andzero, one or more outputs
Inputs and outputs are all considered signals
Unlike circuit-oriented simulators (e.g. Spice),Simulink has no knowledge of whether a signal isvoltage, current, power, torque, speed, , which
makes it a very general tool for simulations of various dynamicalsystems, but
requires a user to decide which signals are inputs and which signalsare outputs, and make block connections to correctly model system
equations; as a result, Simulink block diagrams may not be asintuitive as circuit diagrams
8/12/2019 Lab01 Simulink Tutorial
23/23
End of tutorial