
ffi
Modern Po
-
cos 0+
C
=
0
at
r
=
0
givinl
C
=
1. So the equation for output becomes
-
cos 0 +
l. Thus naturally, it starts from
0 at t
=
0 and
reaches its
peak
value
of 2 at
0= n,
i.e.
3.I4.
10. To
rectifv
this error. double click on Inte block and in the initial
conditions
enter
-
1 which should
be the output of the block at t
=
0. Now
run the simulation
again and see for
yourself
that
the
result is correct.
Some
Commonly
used
Blocks
1. Integrator
We have already described
its use in the above example.
2.
Transfer
function
Using
this block
you
can simulate a transfer function
of the
form Z(s)
=
N(s)/D(s), where
N(s) and D(s) are
polynomials
in s.
You
can double click the
block and enter the coefficients of s in numerator
and denominator
of the expression in ascending
order
of
s
which are to
be
enclosed
inside
square brackets and separated by.a
space.
3. Sum You can find this block under
Math
in
Simulink
block. By default,
it has two
inputs with both
plus
signs.
You
can
modify it to have required
number
of inputs to be
surnmed up by specifying a string of + or
-
depending
upon the inputs. So if there are
3
inputs
you
can
give
the list
of signs as +
- -
. This
will
denote
one
positive
input and two inputs
with
-
signs which
are often used to simuiate negative
feedback.
4.
Gain This block is also found under
Math in Simdlink block. It is used
to
simulate
static
eain.
It can even have fractional
values to act
as
attenuator.
5.
Switch This block is available under
Non-linear block in Simulink. It
has
3
inputs
with the top irrput being numbered
1. When the input number
2 equals or exceeds the threshold value
specified in the
properties
of this
block, it allows input number 1 to
pass
through, else it allows input
number
3 to
pass
through.
6. Mux
and Demux These blocks are available under
Signals and systems
block in
Simulink.
The Mux block combines
its inputs into a single
output
and
is mostly used to form a vector
out of
input
scalar
quantities.
Demux
block
does the reverse thing. It splits
the vector
quantity
into multiple
scalar outputs.
7. Scope We have already described its
use. However; if
you
are
plotting
a
large number of
points,
click on
properties
toolbar
and select Data
History
tab. Then uncheck the Limit
data
points
box so that all
points
are
plotted.
Also when the rvaveform does
not appear smooth, in the
general
tab
of
properties
toolbar, select
sample time instead
of
decimation
in the
sample
time box
and
enter a suitable value like
le-3
(10-3).
The scope
then uses the value at sample-time interval
to
plot.
8.
Clock This block is used to supply
time as a source input and is
available
in Sources block under
Simulink.
,*rr-rr r^t
in Sources block under
Simulink. We have
made
use of this
block in
stability studies to
provide
constant mechanical
input.
generate
a sine
wave
of any amplitude, frequency
and
phase.
The
reader is encouraged
to
work
out, the
examples given
in this
Appendix to
gain greater
insight into
the software.
G.8 SCRIPT AND FUNCTION FILES
Types of m-files
There are two types
of
m-files
used in Matlab
programming:
(i)
Script
m-file
-
This
file needs no input
parameters
and
does
not
return
any values as output
parameters.
It is
just
a set
of Matlab
statements
which
is
stored in a file so that one can
execute this
set by
just
typing the
file name in front of the command
prompt,
eg.
prograrnmes
in
G2
to Gl8
are script files.
(ii)
Function m-files
-
This file
accepts input agruments
and
return
values as
output
parameters.
It
can
work
with
variables
which
belong to the
workspace
as well as
with
the
variables which
are local
to the
functions.
These are useful for making
your
own function
for
a\
particular
application, eg. PolarTorect.m in
Gl
is a
function
m-file.
The basic
structure
of
function m-file is
given
below:
(a)
Function definition line
-
This is
the first line
of a function.
It
specifies
function name,
number and
order of input variables.
Its syntax
is- function
[output
variables]
=
function-name
(list
of input
variables)
(b)
First line of help
-
Whenever help is requested
on this funciton
or look
for is executed MATLAB displays
this
line.
Its
syntax is
-
Vo
function-name
help
(c)
Help
text
-
Whenever help is requested
on the
function-name
help
text
is displayed by Matlab in addition to first
help line.
Its syntax is
-
Vo
function-name
(input
variables)
(d)
Body
of the function
-
This consists
of codes
acting
on the set
of
input
variables to
produce
the output variables.
Tlccr nqn fhrrs rlcwelnn hic/hcr nrrrn rtrntrrqrnc end fi'rnnfinnc
qnA qAA
fham fn fha
LarvrII
uv ulv
existing library of functions and blocks.
G.9
SOME SAMPLE EXAMPLES
SOLVED BY
MATLAB
In
this
section 18 solved examples
of
this
book
are solved
again using
MATLAB/SIMULINK
to encourage the
reader
to solve more
power
system
problems
using MATLAB.