Page 861 - Mechatronics with Experiments
P. 861
®
®
MATLAB , SIMULINK , STATEFLOW, AND AUTO-CODE GENERATION 847
<signal 1>
<signal 2>
Pulse gen
<signal 3>
Bus creator Bus selector
Sine wave
Signal Mux Demux Scope
generator
FIGURE A.22: Connection signal management blocks to simplify graphical display: Mux,
Demux, Bus Create, and Bus Selector blocks used in an example.
Signal Signal
generator generator
simin In 1 Out 1 simout
From To workspace
workspace
Subsystem
untitled.mat untitled.mat
From file To file
®
FIGURE A.23: Input sources and output destinations for the data of a Simulink model.
interface to define groups of signals (i.e., three different groups of signals), then within each
group define individual signals (i.e., input functions r (t), r (t), r (t)). Each signal (such as
1
2
3
r (t)) function can be defined using the main interface tools (such as constant, step, pulse,
1
rectangular, triangular signal type).
®
There are three main “function” blocks in the Simulink block library (Figure A.24):
1. ‘MATLAB function block” (like sin(), exp(), but not an expression) which accepts
vector input and provides vector output. It allows selection of a single MATLAB ®
function. It does not allow typing an expression.
MATLAB
Function sin(u(1)*exp(2.3*(–u(2)))) u Myfcn y
MATLAB Fcn Fcn
Embedded
MATLAB function
®
®
®
FIGURE A.24: Function blocks in Simulink : MATLAB Function (a single MATLAB function
such as “sin()” or ’cos()’). The Fnc() allows an expression (such as “2 ∗ sin(x)-5 ∗ cos(y)”). The
®
Embedded MATLAB Function is linked to an M-function script file and is the most general
purpose block among them where any desired logic can be implemented.