Page 850 - Mechatronics with Experiments
P. 850
836 MECHATRONICS
®
®
MATLAB Function ode45() for ODE Solution MATLAB provides numer-
ical integration functions to solve differential equations, some of which are as follows:
[t, x]= ode45(’ODE_FunctionName’, t_vector, x_initial)
[t, x]= ode23(’ODE_FunctionName’, t_vector, x_initial)
where “ODE_FunctionName” is the name of the M-function file that has the differential
equations that describes the dynamics of the system, t vector can be either [t , t ] beginning
o f
and ending time interval of the simulation and the algorithm decides on the number of
intermediate solution points or it can be a vector of time points at which the solution is to
be obtained and returned at the [t, x] output vector, x initial is the initial conditions for states
at the beginning time t . The difference between different numerical integration methods
0
(above functions, ode45(), ode23()) are about their efficiency and suitability in dealing with
different types of dynamic systems, such as “stiff” numerical problems. A “stiff” numerical
problem is one that has low and very high frequency (sudden changes in the dynamics, i.e.,
impact problems) content in the solution.
A.2 SIMULINK ®
Simulink ® is a graphical modeling and simulation software tool which runs as part of
®
the MATLAB ® package. In MATLAB , a dynamic system is modeled using M-files
which holds the model description in text file format written in MATLAB ® language.
®
In Simulink , a system is modeled using graphical block diagrams and the connections
between the blocks. Therefore, the graphical representation of the model is easier to under-
stand and facilitates better communication between different users working on the same
model.
®
A model in Simulink is:
1. a collection of blocks,
2. their inter-connections, and
3. the parameters of each block.
®
A typical model development using Simulink involves the following steps:
1. Given a mathematical and logical description of a dynamic system and control algo-
®
rithm, build the model of the system using Simulink blocks from the block library.
This involves selecting a number of blocks from the Simulink ® block library, and
making the connections between them.
2. Setup the parameters of each block. Double-clicking on a block brings up the user
interface menu for the block which allows us to setup the parameters of the block,
i.e. the value of the gain for a “Gain” block. Numerical values can be constants
directly typed in the user interface dialog box or can be variables where the val-
ues of the variables are assigned in the MATLAB ® Workspace by either directly
®
making assignment statements in the MATLAB Command Window or placing the
assignment statements into a script-M file (the recommended method), i.e. filename
“Filename_Parameters.m.”
3. Setup the simulation conditions on the “Model Window’s Simulation” menu item,
(a) select the integration algorithm related parameters, simulation time interval,
(b) select the variables to be saved and plotted and connect them to the appropriate
®
Simulink blocks (Scope, To Workpace, etc.).