You are on page 1of 16

SIMULINK Linear & Non-Linear Systems

SIMULINK
Linear and non-linear
Systems
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth
SIMULINK Linear & Non-Linear Systems
SIMULINK Library Continuous
Elements for modelling continuous-time systems
Delays
(s1)
s(s+1)
ZeroPole
Variable
Transport Delay
Transport
Delay
1
s+1
Transfer Fcn
x = Ax+Bu
y = Cx+Du
StateSpace
Memory
s
1
Integrator
du/dt
Derivative
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 1
SIMULINK Linear & Non-Linear Systems
From ODE to ContinuousBlock
Example: spring pendulum
ODE: m x(t) +k x(t) = 0
Solution in time domain:
x(t) = x
0
cos (
0
t) +
v
0

0
sin(
0
t)
Transform to frequency domain:
Transform function X(s) =
1
s
2
+
2
0
L
0
L
0
k
m
x
in SIMULINK:
1
s +2
2
Transfer Fcn
(with initial outputs)
Scope1
0
Constant
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 2
SIMULINK Linear & Non-Linear Systems
Examples for Continuous
Resetting of Simulink Integrator Block:
Scope
>=
Relational
Operator
1
s
x
o
Integrator 2
Constant1
0.5
Constant
Anfangswert
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 3
SIMULINK Linear & Non-Linear Systems
Linearisation
Linearisation of simulation models at arbitrary
operating point
Command:
[A,B,C,D] = linmod(sys,x,u,para,xpert,upert)
[Ad,Bd,Cd,Dd] = dlinmod(sys,Ts,x,u)
Further MatlabCommands from Control System
Toolbox for analysing (ss, tf, zpk, bode, lsim)
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 4
SIMULINK Linear & Non-Linear Systems
Find a point of equilibrium
A trim point (point of equilibrium) corresponds to the
steady state of a dynamic system
x = 0
Command: [x,u,y] = trim(sys, x0, u0, y0)
further options help trim
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 5
SIMULINK Linear & Non-Linear Systems
SIMULINK Library Nonlinear
Elements for modelling of physical non-linearities
Switches
Switch
Saturation Relay
Rate Limiter Quantizer
Multiport
Switch
Manual Switch
Dead Zone
Coulomb &
Viscous Friction
Backlash
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 6
SIMULINK Linear & Non-Linear Systems
Example for Nonlinear
Example for Quantizer
quantisierte Parabel
ausgabe
To Workspace
Quantizer
Clock
f(u)
(u(1)5)^2 + 3
Parabel
Example for Backlash
ausgabe
To Workspace
Signal
Generator
Rate Limiter
1
Constant
Backlash
u
y
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 7
SIMULINK Linear & Non-Linear Systems
SIMULINK Library Functions & Tables
Tables
Programmable functions
system
SFunction
MATLAB
Function
MATLAB Fcn
LookUp
Table (2D)
LookUp
Table
f(u)
Fcn
etc.
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 8
SIMULINK Linear & Non-Linear Systems
Examples for Function & Tables
Examples for LookUp Table
auslese
To Workspace
Ramp LookUp
Table
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 9
SIMULINK Linear & Non-Linear Systems
Algebraic loops
direct feedthrough: Output port
of a block drives input port of the
same block, i.e. input depends on
output at the same time
Sum
u
y
Blocks with direct feedthrough: Sum, Gain, Product
(State Space, Integrator, Transfer Function, ZeroPole)
Solution with Algebraic Constraint:
f(z) z
Solve
f(z) = 0
Algebraic Constraint
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 10
SIMULINK Linear & Non-Linear Systems
Example for algebraic loops
f(z) =
1
7
z
3

1
28
sinz z 5 = 0
Sum
(1/28)* sin(u)
Fcn1
(1/7)* u^3
Fcn
3.9708653342418
Display 5
Constant
f(z) z
Solve
f(z) = 0
Algebraic Constraint
z
z
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 11
SIMULINK Linear & Non-Linear Systems
SFunctions
Self-programmable functions
Use SFunctionBlock in SIMULINKModel
programmable in
Matlab (MFiles)
C, C
++
, Fortran, Ada (MEX Files)
Integration of earlier written programmes
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 12
SIMULINK Linear & Non-Linear Systems
Example for SFunctions
PT
1
:
Transfer function: Y (s) =
1
1 +sT
U(s)
or state space: x =
1
T
x +
1
T
u
y = x
y
To Workspace Step
pt1sfun
SFunction
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 13
SIMULINK Linear & Non-Linear Systems
Example for SFunctions
function [sys,x0,str,ts] = pt1sfun(t,x,u,flag,T)
A = [-1/T]; % State matrix % Unexpected flags %
B = [ 1/T]; % Input matrix otherwise % error handling
C = [ 1 ]; % Output matrix error([Unhandled flag = ,num2str(flag)]);
D = [ 0 ]; % Feedthrough matrix=0 end
switch flag, % end pt1sfun
% Initialization %
case 0, %=====================
[sys,x0,str,ts]=mdlInitializeSizes(A,B,C,D); % mdlInitializeSizes
%=====================
% Derivatives % %
case 1, function [sys,x0,str,ts]=...
sys=mdlDerivatives(t,x,u,A,B,C,D); mdlInitializeSizes(A,B,C,D)
% Outputs % sizes = simsizes;
case 3,
sys=mdlOutputs(t,x,u,A,B,C,D); sizes.NumContStates = size(A,1);
sizes.NumDiscStates = 0;
% not used flags sizes.NumOutputs = size(C,1);
case {2, 4, 9},
sys=[]; sizes.NumInputs = size(B,1);
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 14
SIMULINK Linear & Non-Linear Systems
Example for SFunctions
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1;
%====================
sys = simsizes(sizes); % mdlOutputs
%====================
x0 = zeros(size(A,1),1); %
function sys=mdlOutputs(t,x,u,A,B,C,D)
str = [];
sys = C*x + D*u;
ts = [0 0];
% end mdlInitializeSizes % end mdlOutputs
%===================
% mdlDerivatives
%===================
%
function sys=mdlDerivatives(t,x,u,A,B,C,D)
sys = A*x + B*u;
% end mdlDerivatives
Matlab/Simulink
Dipl.-Ing. U. Wohlfarth 15

You might also like