Date post: | 07-Apr-2018 |
Category: |
Documents |
Upload: | nida-rasheed |
View: | 233 times |
Download: | 0 times |
of 27
8/6/2019 An Introduction to MatLAB & Simulink1
1/27
Lab # 1
An Introduction
To MatLAB &
Simulink
8/6/2019 An Introduction to MatLAB & Simulink1
2/27
Basic MatLAB Commands
MatLAB Syntax:
Do Not Display Results: Comma
after command
Matrix Creation: [1 2; 3 4] =
43
21
8/6/2019 An Introduction to MatLAB & Simulink1
3/27
Basic MatLAB Plotting
Plotting x and y: plot(x(),y())
Transfer Function
Tf([ Numerator Coefficients],[ Denominator Coefficients])
i.e. sys = tf([1],[1 3 2]);
23
1
2
!
sssys
8/6/2019 An Introduction to MatLAB & Simulink1
4/27
Basic MatLAB Commands
Conversions
Transfer Function To State Space [A,B,C,D] = tf2ss([Num],[Den]);
State Space To Transfer Function [Num, Den] = ss2tf(A,B,C,D);
Transfer Function To Zero/Poles [z,p,k] = tf2zp([Num],[Den]);
Zero/Poles To Transfer Function [Num, Den] = zp2tf(z,p,k);
State Space To Zero/Poles [z,p,k] = ss2zp(A,B,C,D,iu);
Zero/Poles To State Space [A,B,C,D] = zp2ss(z,p,k);
8/6/2019 An Introduction to MatLAB & Simulink1
5/27
Basic MatLAB Commands
8/6/2019 An Introduction to MatLAB & Simulink1
6/27
Basic MatLAB Commands
Symbolic Variables syms variable;
i.e. syms t
Laplace Transforms laplace(function);
i.e. syms t;
f = sin(t);
laplace(f)
Inverse Laplace Transforms ilaplace(function);
i.e. syms s;
f = (s+1)/(s^2+3s+2);
ilaplace(f)
8/6/2019 An Introduction to MatLAB & Simulink1
7/27
Basic MatLAB Commands
Integration int(function, variable)
i.e. syms x;
f = sin(x);
int(f,x)
Differentiation diff(function, variable)
i.e. syms x;
f = sin(x);
diff(f,x)
8/6/2019 An Introduction to MatLAB & Simulink1
8/27
Basic MatLAB Commands:
Examples
8/6/2019 An Introduction to MatLAB & Simulink1
9/27
MatLAB:
SpecialCharacters
8/6/2019 An Introduction to MatLAB & Simulink1
10/27
Basic MatLAB Plots
For the next three plots and simulink models,
this is the system used:
Spring-Dashpot Mass Systemm=1 Input Sine
b=4 Amp=50
k=2 Freq=5
Fkxxbxm !
24
1
2
!
sssF
sX
? A ? A
? A? A Fxy
Fxx
001
1/1
0
1/41/2
10
!
!
M
k
F
b
x
8/6/2019 An Introduction to MatLAB & Simulink1
11/27
Basic MatLAB Plots Bode Diagrams
A graphical way
of representing
systems through
a magnitude and
phase plot. Using
the frequency domain
these plots can be
obtained. These
can be used in:Control Systems
Dynamics
Electronics
MatLAB Command: bode(sys) or bode(tf([Num],[Den]))
8/6/2019 An Introduction to MatLAB & Simulink1
12/27
Basic MatLAB Plots Root Locus
Diagram
A diagram of
the poles and
zeros of a system,
using a real and
imaginary axes.
rlocus(sys) or
rlocus(tf([Num],[Den]))
8/6/2019 An Introduction to MatLAB & Simulink1
13/27
Basic MatLAB Plots Nyquist
DiagramThis allows the
prediction of
stability andPerformance
using the systems
open loop form.
nyquist(sys) or
nyquist(tf([Num],[Den]))
8/6/2019 An Introduction to MatLAB & Simulink1
14/27
Introduction To Simulink
Simulink is a graphical representation of
systems, differential equations, or problems
encountered in engineering fields. Blocks
can be assembled to reproduce almost
anything as long as it can be modeled
mathematically. Simulink has become an
important part of aeronautical, astronautical,computer, electrical, and mechanical
engineering programs and industries.
8/6/2019 An Introduction to MatLAB & Simulink1
15/27
Simulink: Computer Integrated
Simulink can be used to control systems
with the correct hardware and software.
Texas Instruments and other electronic
equipment manufacturers creates circuit
boards for integration with a PC running
Simulink. Output can be directly saved to
a computer and analyzed to improve themodel or write the report, more efficiently
than in the past.
8/6/2019 An Introduction to MatLAB & Simulink1
16/27
Simulink Toolboxes
These are some of the
toolboxes simulink has.
We will use only the first
toolbox Simulink and
Simulink Extras furtherdown.
8/6/2019 An Introduction to MatLAB & Simulink1
17/27
Simulink: Most Commonly Used
Blocks
These are the most commonly used blocks
for Mechanical Engineers.
8/6/2019 An Introduction to MatLAB & Simulink1
18/27
Simulink: Most Commonly Used
Blocks
These are
the mostcommonly
used blocks
for Electrical
Engineers.
8/6/2019 An Introduction to MatLAB & Simulink1
19/27
Simulink: Creation Of A Model
1. A mathematical model has to be finished or aprior simulation had to been performed.
2. Create the block diagram by opening a newmodel sheet and grabbing and dropping theblocks onto the model sheet.
3. Arrange blocks in the order that the modelshows and connect them by dragging thearrow coming out of the block to the next block
or clicking on both blocks while holding downcontrol.
4. Make sure the model is correct before runningthe simulation. Then run the simulation.
8/6/2019 An Introduction to MatLAB & Simulink1
20/27
Simulink: Creation Of A Model
8/6/2019 An Introduction to MatLAB & Simulink1
21/27
Simulink: Model Parameters
Changing
the
simulation
parameters
will help or
hurt your
model
depending
on what ischanged.
8/6/2019 An Introduction to MatLAB & Simulink1
22/27
Simulink: Output Of The Model
There are
several
ways to use
or view the
data
received
from the
model.
8/6/2019 An Introduction to MatLAB & Simulink1
23/27
Simulink: Example 1 & 2
8/6/2019 An Introduction to MatLAB & Simulink1
24/27
Simulink: Example 3
8/6/2019 An Introduction to MatLAB & Simulink1
25/27
Simulink: Lab 2 Diagram
8/6/2019 An Introduction to MatLAB & Simulink1
26/27
Simulink: Moderate to Advanced
Models
Research Model: Modeling and
control of swimming robotic fish
8/6/2019 An Introduction to MatLAB & Simulink1
27/27
An Introduction To MatLAB
& Simulink