You are on page 1of 23

Introduction to Simulink

Part One

Pavel Karban

University of West Bohemia,


Faculty of Electrical Engineering,
Department of Theory of Electrical Engineering

Regensburg, 24. – 28.7. 2006


Contents:

1. What is Simulink?
2. Getting Started
3. Dynamic System Definition
4. Preparing Problem for Simulation
5. Creation of Simuling Model – Standard Block Descripton
6. Analyzing Results

Regensburg, 24. – 28.7. 2006


1. What is Simulink?

Simulink (SIMUlation and LINK) is an extension of


MATLAB by Mathworks Inc

-intended to modeling, simulating, and analyzing of


dynamical systems under GUI
-linear and nonlinear analyses
-hierarchical model

Regensburg, 24. – 28.7. 2006


2. Getting Started

Simple model – Sine wave and its integral

1. Start Simulink
a)From Command Window: type simulink
b)From Main toolbar

Regensburg, 24. – 28.7. 2006


2. Getting Started

2. Simulink Library Browser

3. Create new model (by new file icon)


Regensburg, 24. – 28.7. 2006
2. Getting Started

4. Workspace for your model

5. Explore Library browser for become familiarized

Regensburg, 24. – 28.7. 2006


2. Getting Started

6. Drag from Sources group block with name Sine


Wave to workspace

7. Save your work to harddisk

Regensburg, 24. – 28.7. 2006


2. Getting Started

8. Continue to build model by adding blocks to your


model window.

From Sinks library: Scope


From Continuous library: Integrator
From Signal Routing library: Mux
Regensburg, 24. – 28.7. 2006
2. Getting Started

8. Continue to build model by adding blocks to your


model window.

From Sinks library: Scope


From Continuous library: Integrator
From Signal Routing library: Mux
Regensburg, 24. – 28.7. 2006
2. Getting Started

9. Establish connection between the blocks

To make a connection: left-click while holding down


the control key (on your keyboard) and drag from
source port to a destination port.
Regensburg, 24. – 28.7. 2006
2. Getting Started

10. Run the simulation

Double click on the Scope block to display of


the scope. Regensburg, 24. – 28.7. 2006
2. Getting Started

NOTE:
From math:
Primitive function to sine function is –cosine function

Real integrator:
Definite integral of input variable (area under sine
wave function between 0 and t)
t
y (t )   u (t ) dt
0

Regensburg, 24. – 28.7. 2006


3. Dynamic System Definition

A dynamic system is in fact a way how to describe


real objects and phenomena. It is possible to say,
that the dynamic system is a set of variables and
relations. Dynamic system can describe relations
between variables and causality between
variables as well. Variables describing an object or
a phenomenon can be divided into to sets –
parameters and state of system.
State of system is such a set of variables the
knowledge of which and the input function, with
the equation describing the dynamics, will provide
the future state and output of the system.
Regensburg, 24. – 28.7. 2006
3. Dynamic System Definition

The state of a system is described by a set of first-order differential


equations in terms of the state variables. This set of differential
equations can be written in matrix form as follows:

x  Ax  Bu
In general the output of dynamic system can be related to the
state variables and the input signal by the output equation
y  Cx  Du
Regensburg, 24. – 28.7. 2006
3. Dynamic System Definition

The state of a system is described by a set of first-order differential


equations in terms of the state variables. This set of differential
equations can be written in matrix form as follows:

x  Ax  Bu
In general the output of dynamic system can be related to the
state variables and the input signal by the output equation
y  Cx  Du
Regensburg, 24. – 28.7. 2006
3. Dynamic System Definition

.
u x x y
B S integrator C S

x  Ax  Bu
y  Cx  Du x inner state vector
u input vector
x output vector

A matrix of dynamics of the system


B input matrix
C output matrix
D matrix of direct acting of input to output
Regensburg, 24. – 28.7. 2006
4. Preparing Problem for Simulation
Simulate electrical circuit

Given circuit can be described


by this equation:
diL
R2iL  L 0
dt
With initial condition:
U0
iL (0) 
R1  R2

TASK: Find time evolution of current iL

Regensburg, 24. – 28.7. 2006


4. Preparing Problem for Simulation
After some rearrangement we will get:
diL R2
  iL
dt L
It is possible to rewrite previous
equation in the "matrix" form

x1  Ax1
y  Cx1
where
R2
x1  i L A  105 C 1
L
Initial condition (integrator):
U0
x(0)   5 103
R1  R2
Regensburg, 24. – 28.7. 2006
5. Creation of Simuling Model
Block diagram of simple dynamic system

Simulink model of simple dynamic system


1
s
Integrator Scope

Gain

-1e3/10e-3

Regensburg, 24. – 28.7. 2006


5. Creation of Simuling Model
Setting up Initial condition
(double click on Integrator block)

Regensburg, 24. – 28.7. 2006


5. Creation of Simuling Model
Setting up simulation preferences
(menu item Simulation > Configuration Parameters …)

Regensburg, 24. – 28.7. 2006


6. Analyzing Results
Time evolution of current iL
(double click on Scope block)

Regensburg, 24. – 28.7. 2006


Thank you for your kind attention

Regensburg, 24. – 28.7. 2006

You might also like