Professional Documents
Culture Documents
Simulation
4.1 Introduction to MATLAB/Simulink:
MATLAB is a numerical computation and simulation tool that was developed into a
commercial tool with a user friendly interface from the numerical function libraries LINPACK
and EISPACK, which were originally written in the FORTRAN programming language.
As opposed to the well-known computer algebra programs, such as MAPLE or
MATHEMATICA, which are capable of performing symbolic operations and, therefore,
calculating with mathematical equations as a person would normally do with paper and pencil, in
principle MATLAB does purely numerical calculations. Nevertheless, computer algebra
functionality can be achieved within the MATLAB environment using the so-called symbolics
toolbox.
Computer algebra programs require complex data structures that involve complicated
syntax for the ordinary user and complex programs for the programmer. MATLAB, on the other
hand, essentially only involves a single data structure, upon which all its operations are based.
This is the numerical field, or, in other words, the matrix. This is reflected in the name: MATLAB
is an abbreviation for MATrix LABoratory.
MATLAB limits itself to the basic data structure of the matrix, then MATLAB syntax
remains very simple and MATLAB programs can be written far more easily than programs in
other high level languages or computer algebra programs. A command interface created for
interactive management without much ado, plus a simple integration of particular functions,
programs, and libraries supports the operation of this software tool. This also makes it possible to
learn MATLAB rapidly.
33
M V G R College of Engineering
Chapter 4
MATLAB is not just a numerical tool for evaluation of formulas, but is also an
independent programming language capable of treating complex problems and is equipped with
all the essential constructs of a higher programming language. Since the MATLAB command
interface involves a so-called interpreter and MATLAB is an interpreter language, all commands
can be carried out directly. This makes the testing of particular programs much easier.
MATLAB offers an intuitive language for expressing problems and their solutions both
mathematically and visually.
Typical uses include:
Numeric computation and algorithm development.
Symbolic computation (with the built-in Symbolic Math functions).
Modeling, simulation and prototyping.
Data analysis and signal processing.
Engineering graphics and scientific visualization.
34
M V G R College of Engineering
Chapter 4
comprehensive block library of sinks, sources, linear and nonlinear components, and connectors.
We can also customize and create our own blocks.
Models are hierarchical, so we can build models using both top-down and bottom-up
approaches. We can view the system at a high level, and then double-click on blocks to go down
through the levels to see increasing levels of model detail. This approach provides insight into
how a model is organized and how its parts interact.
After we define a model, we can simulate it, using a choice of integration methods, either
from the Simulink menus or by entering commands in MATLABs command window. The menus
are particularly convenient for interactive work, while the command-line approach is very useful
for running a batch of simulations. Using scopes and other display blocks, we can see the
simulation results while the simulation is running. In addition, we can change parameters and
immediately see what happens, for what if exploration. The simulation results can be put in the
MATLAB workspace for post processing and visualization.
Model analysis tools include linearization and trimming tools, which can be accessed from
the MATLAB command line, plus the many tools in MATLAB and its application toolboxes. And
because MATLAB and Simulink are integrated, we can simulate, analyze, and revise your models
in either environment at any point.
One of the key features of Simulink is that it is built on top of MATLAB. As a result,
Simulink users have direct access to the wide range of MATLAB-based tools for generating,
analyzing, and optimizing systems implemented in Simulink. These tools include MATLAB
Application Toolboxes, specialized collections of M-files for working on particular classes of
problems.
Simulink can be used to explore the behavior of a wide range of real-world dynamic systems,
including electrical circuits, shock absorbers, braking systems, and many other electrical,
mechanical, and thermodynamic systems. Simulating a dynamic system is a two-step process
with Simulink. First, we have to create block diagram, using the Simulink model editor, that
graphically depicts time-dependent mathematical relationships among the system's inputs, states,
35
M V G R College of Engineering
Chapter 4
and outputs. Then we simulate the system represented by the model from a specified start time to
a specified stop time.
36
M V G R College of Engineering
Chapter 4
contained in a signal, based on a finite set of data. Using pwelch command the response has been
found in frequency domain.
-Kms
z1
1
s
z2
z1
z3
1
s
z2
z3
-K-
i-i
-K-
k1+k2+k3
c1+c2+c3
1
r2
-K-
p3
P-1
-K-
p2
P'-1
3
z12
k2
z13
c2
z1-1
k3
z23
z1'-1
z2-1
10
c3
z22
R-1
R'-1
2
-K-
r3
-K-
z33
z2'-1
5
z32
k1
z3-1
c1
z3'-1
ms z c1 ( z1 1 ) c2 ( z 2 2 ) c3 ( z 3 3 ) k1 ( z1 1 ) k2 ( z2 2 ) k3 ( z3 3 ) 0
..(4.1)
37
M V G R College of Engineering
Chapter 4
1
c1 ( z1 1 ) c2 ( z 2 2 ) c3 ( z 3 3 ) k1 ( z1 1 ) k2 ( z2 2 ) k3 ( z3 3 )
ms
..(4.2)
These equations can be represented with gain blocks, integrator block and summation blocks
For the equation 4.2 first we will model the integrals of the accelerations of the masses
Insert an Integrator block (from the linear block library) and draw lines to and from its
input and output terminals.
Label the input line "z1" (for acceleration) and the output line "z2" (for velocity) by double
clicking in the empty space just above the line.
Draw a line from its output and label it "z3" (for displacement).
We have taken a multi degree freedom system, in order to completely model the above
equation we need accelerations and velocities of other masses. For that five more pair of
integrators has been modeled. If we model the all of them in a single window the model will be
more confusing for that subsystems have been used. Each equation has been modeled in separate
subsystem. The variables that we are commonly exchanging among the equations are their
displacements, velocities and accelerations. The three variables are taken out of the each
subsystem by using out block. Using a bus creator the three variables can be converted to single
signal. All such signals have been added in order to generate a signal that contains all the
variables. Bus selectors are used to get the required variables from the signal. the parent diagram
for simulink vehicle model consisting of subsystems is as shown in fig 4.2
The equations can be represented with gain block (for 1/ms) and two summation blocks.
Insert a Gain block (from the Linear block library) one attached to the input of the
integrator pairs.
38
M V G R College of Engineering
Chapter 4
Edit the gain block corresponding to ms by double-clicking it and changing its value to
"1/ms".
There are number of forces acting on the mass all of them have to be added, for that two
summation blocks have been included all damping forces are added together and these are added
to the spring forces in another summation block. The force can be obtained by multiplying the
distances by spring constants and velocities by damping coefficients. Insert gain blocks
corresponding to each force and change the parametric value to their corresponding spring
constants or damping coefficients. Input line of these gain blocks is connected to their respective
displacements in case of spring forces and velocities incase of damping forces that have been
brought from the other subsystems. The outputs of lines of these blocks are connected to
summation blocks and signs in the parameter block are changed according to the equation above.
Remaining modes of sprung mass has been modeled similar to the sprung bounce mode as above.
M V G R College of Engineering
Chapter 4
-K-
r1
r2
1
s
r1
Gai n
3
r3
1
s
r2
ii
r3
i i -i
-K-
-K-
Gain2
r-2
5
-K-
z2
-K-
z3
b-2
b'-2
6
2
-K-
p2
-K-
p3
p'-2
p-2
7
-K-
z13
3
z1-2
-K-
z12
z1'-2
4
z22
z23
-Kz2-2
-Kz2'-2
Add
Add1
40
M V G R College of Engineering
1
s
z1
ms
z2
z1
-K-
Chapter 4
z3
1
s
z2
z3
-K-
i-i
-K-
k1+k2+k3
c1+c2+c3
1
r2
R-1
R'-1
2
-K-
r3
-K-
-K-
p3
P-1
-K-
p2
P'-1
3
c2
z12
k2
z13
z1'-1
k3
z2-1
10
c3
z22
z1-1
9
z23
k1
z33
z3-1
z2'-1
5
c1
z32
z3'-1
-K-
p1
p2
p3
1
s
p1
ipy
1
s
p2
iii
p3
iii-i
-K-
-K-
p-3
p'-3
6
1
-K-
z2
-K-
z3
b'-3
b-3
7
-K-
r2
-K-
r3
r'-3
r-3
8
-K-
z13
3
z1-3
-K-
z12
z1'-3
4
-K-
z22
z32
z2-3
10
z33
z2'-3
5
-K-
z23
-Kz3-3
-Kz3'-3
41
M V G R College of Engineering
Chapter 4
c4
c4
-Km uf
z31
z31
1
s
z31
z32
z33
1
s
z32
z32
vi
vi-i
z33
z33
-K-
k1
z3
b-6
k1
4
k1
2
p2
5
df
z3-6
c1+c4
z2
velocity
k4
-K-
du/dt
k4
p3
-Kp-6
-Kp'-6
42
M V G R College of Engineering
z21
z22
Chapter 4
du/dt
z23
velocity2
c5
k5
c5
7
drl
k5
-K-
z21
1
s
murl
1
s
z22
z23
-K-
v-i
k3+k6
-K-
-K-
r3
c3
2
k3
5
c3
z2
k3
z3
c3+c6
k3*l2
6
-K-
r2
-K-
p3
k3*l4
c3*l1
3
-K-
p2
c3*l4
z21
z22
du/dt
z23
velocity2
c5
k5
c5
7
drl
k5
-K-
z21
1
s
murl
1
s
z22
z23
-K-
v-i
k3+k6
-K-
p3
c3*l1
3
k3*l2
6
-K-
p2
-K-
r3
c3
r2
k3
5
c3
z2
k3
z3
c3+c6
-Kk3*l4
-Kc3*l4
43
M V G R College of Engineering