Upload
kimberly-kent
View
215
Download
0
Tags:
Embed Size (px)
Citation preview
S i m u l i n kS i m u l i n k
Prof. Muhammad Saeed
Mathematical Modeling and Simulation
UsingMATLABMATLAB
1
2
Introduction How to start?
Block Library Model Blocks Virtual Non-virtual User-defined Ports Time States Continuous Discrete Hybrid Parameters Normal Tunable Sample Time Subsystems
3
4
Creating Models Block Selection
Sources Sinks System Blocks
Block Editing Color Size Alignment Labeling Parameters and states
Connecting BlocksGroup Blocks
5
y
To WorkspaceSine Wave3
Sine Wave2
Sine Wave1
Sine Wave
Scope2
Scope1
Scope
Product
4
Gain2
5
Gain1
4
Gain
30
Display1
200
Display
20
Constant3
10
Constant2
20
Constant1
10
Constant
Add
Model Blocks:
Source Sink Multiplication and Division Addition and Subtraction
6
y3
To Workspace3
y2
To Workspace2
y1
To Workspace1
Sum ofElements
Product3
MatrixMultiply
Product2
Product1
Dot Product
18
Display2
30
Display1
1 1 21 2 21 3 5
Constant7
1 2 34 5 61 1 2
Constant6
[2 2 2 2 2]
Constant5
[1 2 3 4 5]
Constant4
[2 2 2 2 2]
Constant3
[1 2 3 4 5]
Constant2
1 1 21 2 21 3 5
Constant1
Model Blocks:
Sum Dot Product Vector Multiplication Matrix Multiplication
Element by Element By Matrix Rule
7
sin
TrigonometricFunction
y4
To Workspace4
y3
To Workspace3
y2
To Workspace2
y1
To Workspace1
y
To Workspace
floor
Rounding Function
Product of Elements
P(u)O(P) = 7
Polynomial
max
MinMax
eu
Math Function
5
Display1
10
Display
[3x3]
Constant6
-C-
Constant5
[1 2 3 4 5]
Constant4
2 -1 3 3 4 6-3 -1 8
Constant3
2 -1 3 3 4 6-3 -1 8
Constant2
2 -1 3 3 4 6-3 -1 8
Constant1
-10
Constant
|u|
Abs
Model Blocks:Built-in Functions
abs max, min Logarithmic, exponential Trigonometric Polynomial Product Rounding off
8
Model Blocks:User-defined Functions
Embedded Matlab FunctionFunction of Matlab FunctionsMatlab Function
XY Graph
Scope1
Scope
sin(u)*cos(u)
Fcn
MATLABFunction
Exp
u ydampOsc
EmbeddedMATLAB Function
Clock2
Clock1
Clock
9
Differential Equation Models
1.
Sine WaveScope
1s
Integrator
10
Gain
y
To Workspace
Sine Wave
1s
Integrator
10
Gain
Clock
10
Differential Equation Models
2.
Sine WaveScope
1s
Integrator
10
Gain
11
Differential Equation Models
12
Differential Equation Models
13
Differential Equation Models
Step
x' = Ax+Bu y = Cx+Du
State-Space Scope
14
3.
Differential Equation Models
15
Differential Equation Models
Step
x' = Ax+Bu y = Cx+Du
State-Space Scope
16
If else For While switch
17
5
c
10
b
-1
a
else { }In1 Out1
If ActionSubsystem3
elseif { }In1 Out1
If ActionSubsystem2
elseif { }In1
In2Out1
If ActionSubsystem1
if { }In1
In2Out1
If ActionSubsystem
u1
u2
u3
if(u1 ~=0 & u2<10)
elseif(u2<0)
elseif(u3<u2)
else
If
8
Display3
0
Display2
0
Display1
0
Display
8
Constant3
1
Constant2
3
Constant1
10
Constant
IF Block
18
END