Chapter-3: 3.1 Matlab
Chapter-3: 3.1 Matlab
3.1 MATLAB
3.1.1 Introduction
MATLAB is used in wide range of applications, including signal and image processing,
communications, control design, test and measurement, financial modeling and analysis, and
computational biology. Add-on toolboxes (collections of special-purpose MATLAB functions,
available separately) extend the MATLAB environment to solve particular classes of problems in
these application areas.
MATLAB provides a number of features for documenting and sharing your work. You
can integrate your MATLAB code with other languages and applications, and distribute your
MATLAB algorithms and applications.
3.2 SIMULINK
3.2.1 Introduction
Simulink® is an environment for multidomain simulation and Model-Based Design for dynamic and
embedded systems. It provides an interactive graphical environment and a customizable set of block
libraries that let you design, simulate, implement, and test a variety of time-varying systems, including
communications, controls, signal processing, video processing, and image processing.
1) A set of inputs,
2) A set of states, and
3) A set of outputs
A block's output is a function of time and the block's inputs and states (if any). The
specific function that relates a block's output to its inputs, states, and time depends on the type of
block of which the block is an instance. Continuous Versus discrete Blocks Simulink's standard
block set includes continuous blocks and discrete blocks. Continuous blocks respond
continuously to continuously changing input. Discrete blocks, by contrast, respond to changes in
input only at integral multiples of a fixed interval called the block's sample time. Discrete blocks
hold their output constant between successive sample time hits. Each discrete block includes a
sample time parameter that allows you to specify its sample rate. The Simulink blocks can be
either continuous or discrete, depending on whether they are driven by continuous or discrete
blocks. A block that can be either discrete or continuous is said to have an implicit sample rate.
The implicit sample time is continuous if any of the block's inputs are continuous. The implicit
sample time is equal to the shortest input sample time if all the input sample times are integral
multiples of the shortest time. Otherwise, the input sample time is equal to the fundamental
sample time of the inputs, where the fundamental sample time of a set of sample times is defined
as the greatest integer divisor of the set of sample times.
Simulink can optionally color code a block diagram to indicate the sample times of the
blocks it contains, e.g., black (continuous), magenta (constant), yellow (hybrid), red (fastest
discrete), and so on. The block contains block name, icon, and block library that contain the
block, the purpose of the block.
Simulink organizes its blocks into block libraries according to their behavior:
3.2.6 Solvers
Simulink simulates a dynamic system by computing its states at successive time step
solver a specified time span, using information provided by the model. The process of computing
the successive states of a system from its model is known as solving the model. No single
method of solving a model suffices for all systems. Accordingly, Simulink provides a set of
programs, known as solvers, that each embody a particular approach to solving a model. The
Simulation Parameters dialog box allows us to choose the solver most suitable for our model.
Fixed-step solvers solve the model at regular time intervals from the beginning to the end
of the simulation. The size of the interval is known as the step-size. We can specify the step size
or let the solver choose the step size. Generally decreasing the step size increases the accuracy of
the results while increasing the time required to simulate the system.
Variable-step solvers vary the step size during the simulation, reducing the step size to
increase accuracy when a model's states are changing rapidly and increasing the step size to
avoid taking unnecessary steps when the model's states are changing slowly. Computing the step
size adds to the computational overhead at each step but can reduce the total number of steps,
and hence simulation time, required to maintain a specified level of accuracy for models with
rapidly changing or piecewise continuous states.
3.2.6.3 Continuous Solvers
Discrete solvers exist primarily to solve purely discrete models. They compute the next
simulation time-step for a model and nothing else. They do not compute continuous states and
they rely on the model's blocks to update the model's discrete states. We can use a continuous
solver, but not a discrete solver, to solve a model that contains both continuous and discrete
states. This is because a discrete solver does not handle continuous states. If you select a discrete
solver for a continuous model, Simulink disregards your selection and uses a continuous solver
instead when solving the model.
Simulink provides two discrete solvers, a fixed-step discrete solver and a variable-step
discrete solver. The fixed-step solver by default chooses a step size and hence simulation rate
fast enough to track state changes in the fastest block in our model. The variable-step solver
adjusts the simulation step size to keep pace with the actual rate of discrete state changes in our
model. This can avoid unnecessary steps and hence shorten simulation time for multirate models.
The block set can be put to work rapidly. The libraries contain models of typical power
equipment, such as transformers, lines, machines, and power electronics. These models are
proven ones coming from textbooks, and their validity is based on the experience of the Power
Systems Testing and Simulation Laboratory of Hydro-Québec, a large North American utility
located in Canada. The capabilities of the block set for modeling a typical electrical grid are
illustrated in demonstration files. The block set fits well with other specialized analytical tools
you use in the power system community.
1. Three-Phase Source:
2. in port:
Description: In ports are the links from the outside world into a system. Inside a subsystem
block, there is an in port corresponding to each input port on the block. A signal that arrives at an
input port on a subsystem block flows out of the corresponding in port within that block. The
imports within a subsystem block must be numbered consecutively, starting with1.
3. out port:
Description: The Out port block provides a mechanism for labeling a system’s outputs. In a
subsystem, output ports correspond to outputs on the subsystem block.
4. Subsystem:
Description: Subsystem blocks represent one system within another system. Any set of blocks
and lines can be converted to a Subsystem block with the Group command on the options menu.
The Group command removes all selected objects from the active window and replaces them
within a Subsystem block. This new block, when opened, redisplays all of the grouped
objectives.
5. Gain:
Description: The Gain block implements Y=KU, where Y is the output, U is the input, and K is
the specified gain. The Gain block displays scalar gain data entered as variable or a constant. The
block displays the text as it appears in the dialog box.
6. Scope:
Description: While the simulation is running, the Scope block displays the output of the block
driving it. Opening a scope block produces a scope window. The title of this window matches the
name of the block.
Description: The Simplified Synchronous Machine block models both the electrical and
mechanical characteristics of a simple synchronous machine. The electrical system for each
phase consists of a voltage source in series with RL impedance, which implements the internal
impedance of the machine. The value of R can be zero but the value of L must be positive.
8. Voltage Measurement:
Description: The Voltage Measurement block is used to measure the instantaneous voltage
between two electric nodes. The output is a Simulink signal that can be used
9. Breaker:
Description: The Breaker block implements a circuit breaker that is controlled by a Simulink
signal applied on its second input. The control signal must be 0 or 1, 0 for open and 1 for closed.
The arc extinction process is simulated by opening the breaker when the current passes through
zero (first current zero-crossing following the transition of the Simulink control input from 1 to
0). When the breaker is closed, it behaves as a series RL circuit. The R and L values can be set as
small as necessary in order to be negligible compared with external components (typical values
Ron=10m?, Lon=10µH). When the breaker is open, it has infinite impedance. If the breaker’s
initial state is set to 1 (closed), initializes all the states of the linear circuit and breaker initial
current so that the simulation starts in steady-state.
10. Bus bar:
Description: The Bus Bar block is used to interconnect components. It allows multiple electrical
block outputs and inputs to be connected together.
Description: The Current Measurement block is used to measure the instantaneous current
flowing in any electrical block or connection line. The first output provides a Simulink signal
that can be used by other Simulink blocks.
Purpose: Implement an N-phase distributed parameter transmission line model with lumped
losses
Description: The basic elements that form the Excitation System block are the voltage regulator
and the exciter. The voltage regulator consists of a main regulator with gain K a and time constant
Ta and a lead-lag compensator with time constants Tb and Tc. A derivate feedback is also
provided with gain Kf and time constant Tf. The limits Efmin and Efmax are imposed to the output of
the voltage regulator. The upper limit can be constant and equal to Efmax or variable and equal
to the rectified stator terminal voltage Vtf times a proportional gain Kp. If Kp is set to zero, the
former will apply. If Kp is set to a positive value, the latter will apply. The stator terminal voltage
transducer is represented by a first-order low-pass filter with time constant Tr.
Description: The Steam Turbine and Governor implement a steam turbine model, a PID
governor system, and a servo-motor. The static gain of the governor is equal to the inverse of the
permanent droop Rp in the feedback loop. The input to this feedback loop can be selected to be
the gate position or the electrical power deviation by setting the droop reference parameter in the
dialog box to one or zero, respectively.
Description: The Linear Transformer block model shown below consists of three coupled
windings wound on the same core.
Description: The Saturable Transformer block model shown below consists of three coupled
windings wound on the same core.