project-0
project-0
of
Jan2024-May 2024
Experiment 01
Study of Introduction to MATLAB
1. Starting MATLAB
After logging into your account, you can enter MATLAB by double-clicking on the MATLAB shortcut
icon (MATLAB 7.0.4) on your Windows desktop. When you start MATLAB, a special window called the
MATLAB desktop appears. The desktop is a window that contains other windows. The major tools
within or accessible from the desktop are:
You will have noticed that if you do not specify an output variable, MATLAB uses a default variable
ans, short for answer, to store the results of the current calculation.
Note that the variable ans is created (or overwritten, if it is already existed). To avoid this, you may
assign a value to a variable or output argument name. For example,
>> x = 5 * 4 + 2
x = 22
Y = 4×4
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
Create a 2-D line plot of Y. MATLAB® plots each matrix column as a separate line.
figure
plot(Y)
4. Matrix generation
A vector is a special case of a matrix. The purpose of this section is to show how to create
vectors and matrices in MATLAB. As discussed earlier, an array of dimension 1 ×n is called
a row vector, whereas an array of dimension m × 1 is called a column vector. The
elements of vectors in MATLAB are enclosed by square brackets and are separated by
spaces or by commas. For example, to enter a row vector, v, type
>> v = [2 3 8 7]
v=
2 3 8 7
Column vectors are created in a similar way, however, semicolon (;) must separate the components
of a column vector,
>> v=[2 3 1 5; 1 5 6 2; 8 1 9 4]
v=
2 3 1 5
1 5 6 2
8 1 9 4
On the other hand, a row vector is converted to a column vector using the transpose
operator.
The transpose operation is denoted by an apostrophe or a single quote (’).
>> w = v’
w=
2 1 8
3 5 1
1 6 9
5 2 4
Thus, v(1) is the first element of vector v, v(2) its second element, and so forth.
Furthermore, to access blocks of elements, we use MATLAB’s colon notation (:). For example,
to access the first three elements of v, we write,
>> v(1:3)
ans =
2 1 8
where end signifies the last element in the vector. If v is a vector, writing
>> v(:)
produces a column vector, whereas writing
>> v(1:end)
produces a row vector.
Entering a matrix
To enter a matrix A, such as,
A=
9 2 6
4 5 6
7 3 1
type,
>> A = [9 2 6; 4 5 6; 7 3 1]
Note that the use of semicolons (;) here is different from their use mentioned earlier to
suppress output or to write multiple commands in a single line.
7. Output commands
A diode rectifier or uncontrolled rectifier is the converter circuit that converts ac signal into (an
alternating signal) dc signal (unidirectional signal). Uncontrolled rectifier circuits use diodes to
convert ac power to dc power and are divided into two types, single-phase and three-phase.
Again singe-phase uncontrolled rectifiers are divided into two types, they are,
When the ac supply source to the rectifier is turned ON, the positive half cycle of ac input starts.
During the positive half cycle of ac input, point A in the above circuit is made positive with respect to
point B. Due to this, diodes D1 and D2 are forward biased (since their anode terminals are connected
to positive with respect to the cathode), and diodes D3 and D4 are reverse biased (since their anode
terminals are connected to negative with respect to the cathode).
The below shows the waveforms for output voltage Vo, output current Io, and the voltage drop
across diodes.
Idc =2Vm/πR
In the above circuit, we have seen the full wave bridge rectifier with a resistive load where the
output current and voltage will be in phase. However, in practice loads are not purely resistive but
contain inductance in combination with the resistance. Let us see the circuit operation of an
uncontrolled full wave bridge rectifier with RL-load.
The value of average output voltage and output current with RL load is given by,
A single phase bridge converter needs 4 thyristors. This configuration leads to two quadrant
operation. Such a converter is called the two-quadrant converter or fully controlled converter.
Many times the bridge circuit is modified by replacing two thyristors by two diodes. This
configuration leads to one quadrant operation (operation is restricted to first quadrant). Such a
converter is called the one-quadrant converter or a semi converter.
The load on the converter may be purely resistive, inductive (R-L) load or R-L-E load. An R-L-E load
consists of resistance, inductance and motor (E stands for back emf of motor). The load may also
have a battery (emf E) instead of motor.
1. With Resistive Load: A fully controlled full-wave bridge rectifier is shown in Fig. All the four
devices used in the circuit are thyristors TH 1-TH4 for control of output power. In this circuit,
diagonally opposite pair of thyristors are made to conduct, and are commutated,
simultaneously. During the first positive half cycle, thyristors TH 1 and TH3 are forward
biased and if they are triggered simultaneously, the current flows through the load via
thyristor TH1- load-TH3-source. Thus, during positive half cycle, thyristors TH 1 and TH3 are
conducting. During the negative half cycle of the ac input, thyristors TH 2 and TH4 are
forward biased and if they are triggered simultaneously, the current flows through the load
via thyristor TH2- load-TH4-source. Thyristors TH1, TH3 and TH2, TH4 are triggered at the
same firing angle α in each positive and negative half cycles of the supply voltage
respectively. When the supply voltage falls to zero, the current also becomes zero. Thus
thyristors TH1, TH3 in positive half cycle and TH 2 and TH4 in negative half cycle turn off by
natural commutation. The related voltage and current waveforms for this circuit are
depicted in Fig. below.
The voltage waveform at the dc terminals comprises a steady dc component superimposed with
an ac ripple component, having a fundamental frequency equal to twice that of ac supply.
As illustrated in Fig. above, at firing angle α = 60°, thyristors TH 1 and TH3 are triggered. Supply voltage
from this instant appears across the output terminals and forces the current through the load. The
load current Idc is assumed to be constant. This current also flows through the supply and the direction
is from line to neutral, which is taken positive as depicted in Fig.(a) along with the applied voltage. At
instant π, the supply voltage reverses but because of very large inductance L, the current keeps
flowing in the same direction at constant magnitude I dc. Thus the thyristors TH1 and TH3 remain in
conducting state and therefore, the negative supply voltage appears across the output terminals. At an
angle π + α, thyristors TH 2 and TH4 are triggered. With this, negative supply voltage reverse biases
thyristor TH1 through thyristor TH2 and thyristor TH3 through thyristor TH4 of commutating thyristor
TH1 and TH3. The current continues flowing in every half cycle and output voltage is obtained as
depicted in the figure. As illustrated the current is positive when TH 1 and TH3 are conducting and
negative when TH2 and TH4 are conducting.
The average value of output dc voltage can be varied, by varying firing angle α, continuously from
positive maximum to negative maximum, assuming continuous current flow at the dc terminals.
Because the average dc voltage is reversible even though the current flow in the load is
unidirectional, the power flow in the convener can be in either direction. Thus full converter
provides two modes of operation.
(b) Inversion Mode: For firing angle between 90° and 180°, the load voltage is negative which means
that the power is supplied from the load to the source. Waveforms for α = 135° are shown in Fig.
27.16 (b). Such an operation is used in the regenerative braking mode of dc drives and in high
voltage direct current (HVDC) transmission.
A single phase voltage source inverter inverts the DC voltage into square-wave ac or sine-wave ac
voltages. Currently, there are two types of voltage inverters on the market: the first is a full-bridge
voltage source inverter, which consists of four switches, IGBTs, or MOSFETs, and the second is a
single-phase voltage source inverter, which consists of two switches, IGBTs, or MOSFETs. These
voltage source inverter applications include single phase UPS and switching power supplies. These
have been mostly used in high-power static power topologies.
Simulink Model
Similarly, we search and drag all the other component blocks, such as the pulse generator, logic
gate, capacitor, resistor, etc. Then we join the circuit according to our requirements. Now our
single phase voltage source inverter is complete with the help of the MATLAB Simulink library. The
Simulink model circuit can be seen in the figure below.
Simulation
Because both IGBT switches should not be ON at the same time, one gate pulse directly connects
with one IGBT switch, and the other gate pulse is connecting with the other IGBT switch after NOT
Gate. In other words, this circuit works through complementary switching. When we simulate this
circuit at 50% duty cycle, then the output voltage would be half of the supply voltage, which
means
it would be 50 volts, as shown in the figure below.
The ac voltage controller also called as AC Regulator is a static power electronic circuit that converts
fixed ac to variable ac. It accomplishes this task without a change in frequency. It finds application in
heating, lighting circuits, speed control of ac machines, fan regulators, etc, similar to the applications
of an autotransformer.
The circuit of the ac voltage controller is based on either thyristors, TRIACs, SCRs, or IGBTs, which
gives a variable ac at the output when their triggering angle is adjusted or varied. The output voltage
is either increased, decreased, or kept constant by varying the RMS value of input fixed alternating
voltage.
During the positive half cycle of the source voltage VS, SCR T1 is forward biased and SCR T2 is reverse
biased. No conduction of load current takes place until thyristor T1 is triggered at some firing angle α.
So, the entire supply voltage VS appears across thyristor T1 with the same polarity and across T2 with
the reversed polarity. As soon as the thyristor T1 is triggered at the instant ωt = α, T1starts.
Conducting and the entire supply voltage VS,except the drop across T1,appears across the load
resistance.
As long as thyristor T1 in ON state, i.e., from α<ωt<π, voltage across T2 will be VT2 = –VT1 = (ON –
state voltage drop of T1). At ωt=(π+α), thyristor T2 is triggered and it starts conducting. Except for
the small voltage drop across T2,the entire supply voltage appears across the load resistance and
the load current flows. As long as T2 is in ON state, i.e., from(π + α) < ωt < 2π, voltage across T1 will
be VT1 = -VT2= -(ON-state voltage drop of T2).
This process goes on and continues for every cycle as shown in the waveform. For resistance load,
the source current waveform will follow the source voltage waveform i.e., both the voltage and
current of the source will be in phase with each other.
Consider α = Φ (load phase angle) i.e., the ac voltage regulator is operating under steady-state conditions. The
conduction period of SCR T2 is from zero to Φ and from Φ to (π + Φ) SCR T1 will conduct and again from (π + Φ)to
(2π + Φ)SCR T2 will conduct as shown in the waveform below.
The RMS value of output voltage and current with RL load is given by:
Matrix =
9 2 6
4 5 6
7 3 1
Size(Matrix)
Ans =
3 3
V/X
Det(V)
Rand(3,2)
8. Find the diagonal of a Matrix
To find the main diagonal of V, use
Diag(V)
Transpose(C) Or C’
C=
5 1 3
6 5 2
9 4 7
ans =
5 6 9
1 5 4
3 2 7
0.2078
0.4078
0.8482
2.5362
Output :
Alternatively, use outputForm to return the eigenvalues in a diagonal matrix.
D = eig(A,"matrix")
D = 4×4
0.2078 0 0 0
0 0.4078 0 0
0 0 0.8482 0
0 0 0 2.5362
We can use the Matlab built-in function solve() to solve the system of linear equations in Matlab.
First of all, we can define the variables using the syms variable. After that, we can write the
equations in Matlab. After that, we need to use the function solve() to solve the equations. For
example, let’s define some equations in Matlab and find their solution using the solve() function.
See the code below.
yms x y z
eqn1 = 2*x + y + z == 2;
eqn2 = -x + y - z == 3;
eqn3 = x + 2*y + 3*z == -10;
sol = solve([eqn1, eqn2, eqn3], [x, y, z]);
xSol = sol.x;
ySol = sol.y;
zSol = sol.z;
Output:
(x = 3)
(y = 1)
(z = -5)
Syntax r = roots(p) returns the roots of the polynomial represented by p as a column vector. Input
p is a vector containing n+1 polynomial coefficients, starting with the coefficient of xn. For
3 2
example, p = [12 34 1 1] represents the polynomial 12x - 34x + x + 1. A coefficient of 0 indicates
an intermediate power that is not present in the equation.
n
The roots function solves polynomial equations of the form p1x +...+pnx+pn+1=0. Polynomial
equations contain a single variable with nonnegative exponents.
Examples
1. Roots of Quadíatic Polynomial
Solve the equation 3x2−2x−4=0.
Cíeate a vectoí to íepíesent the polynomial, then find the íoots.
Get
p = [12 34 1 1];
r =
roots(p) r
= 2×1
2.7928
0.1942
-0.1537
Steps:-Define the equation and conditions. The second initial condition involves the first derivative
of y. Represent the derivative by creating the symbolic function Dy = diff(y) and then define
the condition using Dy(0)==0.
syms y(x)
ode = diff(y,x,2) ==
cos(2*x)-y; cond1 = y(0) ==
1;
cond2 = Dy(0) == 0;
Solve ode for y. Simplify the solution using the simplify function.
conds = [cond1 cond2];
ySol(x) =
dsolve(ode,conds); ySol =
simplify(ySol)
ySol(x) = 1 - (8*sin(x/2)^4)/3