Você está na página 1de 27

NOIDA INSTITUTE OF ENGINEERING AND TECHNOLOGY

GREATER NOIDA

2017-18
LAB MANUAL
DEPARTMENT OF:

ELECTRICAL AND ELECTRONICS ENGINEERING

SIMULATION LAB I (REE-353)

LAB INCHARGE:

RAGINI MALVIYA

BHARAT BHUSHAN SHARMA


INDEX

EXPERIMENT NO NAME OF EXPERIMENT

1 INTRODUCTION TO MATLAB AND ITS BASIC


COMMANDS

2 DETERMINATION OF ROOTS OF A POLYNOMIAL

3 DETERMINATION OF POLYNOMIAL USING METHOD OF


LEAST SQUARE CURVE FITTING

4 SOLUTION OF DIFFERENTIAL EQUATIONS USING 4th


ORDER RUNGE-KUTTA METHOD

5 DETERMINATION OF TIME RESPONSE OF AN R-L-C


CIRCUIT

6 STEP, RAMP AND IMPULSE RESPONSE OF TRANSFER


FUNCTION

7 GENERATION OF SINGLE AND THREE PHASE


SINUSOIDAL WAVEFORM

8 PWM BASED WAVEFORM GENERATION

9 SINGLE LINE MODELLING OF DC MOTOR

10 SINGLE PHASE UNCONTROLLED HALF WAVE


RECTIFIER USING R AND RL LOAD

11 SINGLE PHASE UNCONTROLLED FULL WAVE


RECTIFIER USING R LOAD

12 THREE PHASE UNCONTROLLED FULL WAVE


RECTIFIER USING R AND RL LOAD
EXPERIMENT NO. 1
OBJECTIVE: INTRODUCTION TO MATLAB AND ITS BASIC COMMANDS

SOFTWARE USED: MATLAB 2009

MATLAB is widely used in all areas of applied mathematics, in education and


research at universities, and in the industry. MATLAB stands for MATrixLABoratory
and the software is built up around vectors and matrices. This makes the software
particularly useful for linear algebra but MATLAB is also a great tool for solving
algebraic and differential equations and for numerical integration. MATLAB has
powerful graphic tools and can produce nice pictures in both 2D and 3D. It is also a
programming language, and is one of the easiest programming languages for writing
mathematical programs. MATLAB also has some tool boxes useful for signal
processing, image processing, optimization, etc.

How to start MATLAB

Mac: Double-click on the icon for MATLAB.

PC: Choose the submenu "Programs" from the "Start" menu. From the "Programs"
menu, open the "MATLAB" submenu. From the "MATLAB" submenu, choose
"MATLAB".

Unix: At the prompt, type MATLAB.

You can quit MATLAB by typing exit in the command window.

The MATLAB environment

Note: From now on an instruction to press a certain key will be denoted by <>, e.g.,
pressing the enter key will be denoted as <enter>. Commands that should be typed at
the prompt, will be written in courier font.

The MATLAB environment (on most computer systems) consists of menus, buttons
and a writing area similar to an ordinary word processor. There are plenty of help
functions that you are encouraged to use. The writing area that you will see when you
start MATLAB, is called the command window. In this window you give the
commands to MATLAB. For example, when you want to run a program you have
written for MATLAB you start the program in the command window by typing its
name at the prompt. The command window is also useful if you just want to use
MATLAB as a scientific calculator or as a graphing tool. If you write longer
programs, you will find it more convenient to write the program code in a separate
window, and then run it in the command window.

In the command window you will see a prompt that looks like >> . You type your
commands immediately after this prompt. Once you have typed the command you
wish MATLAB to perform, press <enter>. If you want to interupt a command that
MATLAB is running, type <ctrl> + <c>.

The commands you type in the command window are stored by MATLAB and can be
viewed in the Command History window. To repeat a command you have already
used, you can simply double-click on the command in the history window, or use the
<up arrow> at the command prompt to iterate through the commands you have used
until you reach the command you desire to repeat.

Useful functions and operations in MATLAB

Using MATLAB as a calculator is easy.

Example: Compute 5 sin(2.53-pi)+1/75. In MATLAB this is done by simply typing


5*sin(2.5^(3-pi))+1/75

at the prompt. Be careful with parantheses and don't forget to type * whenever you
multiply!

Note that MATLAB is case sensitive. This means that MATLAB knows a difference
between letters written as lower and upper case letters. For example, MATLAB will
understand sin(2) but will not understand Sin(2).

Here is a table of useful operations, functions and constants in MATLAB.


Basic Commands

Examples

GIVEN NUMERICAL:

A= 3 2 1
0 3 4
-1 1 -1

B= 1 3 0
2 6 4
-1 0 2
Where A and B are two 3 X 3 matrix

COMMANDS:

>> A= [3 2 1; 0 3 4; -1 1 -1]
>> B= [1 3 0; 2 6 4; -1 0 2]

Sum: A+ B
Subtraction: A–B
Multiplication: A*B
Division: A/B or A\B
Inverse of A: inv(A)

RESULTS:

>> A + B % Sum up matrix A and B


ans:
4 5 1
2 9 8
-2 1 1

>> A – B % Subtract matrix A and B


ans:
2 -1 1
-2 -3 0
0 1 -3

>> A * B % Multiply matrix A and B


ans:

6 21 10
2 18 20
2 3 2

>> A/B % Divides matrix A and B(take inverse of B and


multiply with A )
ans:
-2.1667 1.4167 -2.3333
0 0.5000 1.0000
2.1667 -0.9167 1.3333

>> A\B % Divides matrix A and B(take inverse of A and


multiply with B )
ans:
0.2308 0.1154 -0.8462
-0.1538 0.9231 1.2308
0.6154 0.8077 0.0769

>> inv(A) % inverse of A


ans:
0.2692 -0.1154 -0.1923
0.1538 0.0769 0.4615
-0.1154 0.1923 -0.3462

ADDITIONAL COMMANDS AND RESULTS:

>>a= magic(3) % gives 3 X 3 matrix whose sum from any angle


is same
ans:
8 1 6
3 5 7
4 9 2

>>a= rand(3) % gives any 3 X 3 random matrix


ans:
0.8147 0.9134 0.2785
0.9058 0.6324 0.5469
0.1270 0.0975 0.9575

>> a= ones(3) % gives 3X 3 matrix whose elements are one


ans:

1 1 1
1 1 1
1 1 1

>> b= 2*ones(3) % multiplication of 2 with ones(3)


ans:
2 2 2
2 2 2
2 2 2

>> a+2 % summation of 2 with matrix A


ans:

>> a(2,2) % gives second row and second column element


of matrix A
ans:
1

>>a(2:3, :) %gives second and third row of matrix ‘a’


ans:
1 1 1
1 1 1

>> a(:, 2:3) % gives second and third column of matrix ‘a’

ans:
1 1
1 1
1 1
>> a(2:3,1:2) %gives second and third row and first and
second column of matrix ‘a’
ans:
1 1
1 1

>>a(:,2) % gives second column of matrix ‘a’


ans:
1
1
1

>>a(:,1:2)=[] %delete first and second column


ans:
1
1
1

>>eye(3) %gives 3 X 3 matrix whose diagonal are one


ans:
1 0 0
0 1 0
0 0 1

>> diag(a) % gives diagonal element of matrix ‘a’


ans:
1 0 0
0 1 0
0 0 1
>> b = a’ % gives inverse of matrix ‘a’
ans:
1 1 1

For Determining the eigenvalues and eigenvectors in MATLAB eig function is used. For an
nxn matrix A, eig(A) returns a n x1 column vector whose elements are the eigenvalues of A. The
command in the form
[𝑉 𝐷] = 𝑒𝑖𝑔(𝐴)

Computes both the eigenvalues and eigenvectors of A. V will be a matrix whose columns are
eigenvectors of A and D will be a diagonal matrix whose entries along the diagonal are
eigenvalues of A. The ith column of V, V(:, i), is the eigenvector corresponding to the eigenvalue
D(i,i). For example:

A = [ 1 2 3; 4 5 6; 7 8 9]

>> A = [ 1 2 3; 4 5 6; 7 8 9]
>> eig(A)
>> [V D]=eig(A)

RESULT:

CONCLUSION:
EXPERIMENT NO. 2
OBJECTIVE: DETERMINATION OF ROOTS OF A POLYNOMIAL

THEORY:

POLYNOMIAL:

Polynomials are functions that have the form

The coefficients are often real numbers and which is a nonnegative integer, is
the degree or order of the polynomial.
In MATLAB, Polynomials are described by using a row vector of the coefficients of the
polynomial beginning with the highest power of x and inserting zeros for “missing” terms:

f= [9 -5 3 7]

g= [6 -1 2]

ROOTS OF A POLYNOMIAL:
Roots of a polynomial

are the values of for which . For example, the roots of are -
1 and -2. There are n roots of a polynomial with degree n.
The command “roots” determines the roots of a polynomial. The usage of the function is:
r= roots (p)
Where r is a column vector with the roots and p is a row vector with the coefficients of the
polynomial.
PROGRAM:

Find the roots of the polynomial

>> p = [3 15 0 -10 0 4 0]

>> roots(p)

RESULT:

-4.8613

-0.6925 + 0.3093i

-0.6925 - 0.3093i

0.6232 + 0.2975i

0.6232 - 0.2975i

CONCLUSION: Hence the roots of the given polynomial is obtained


EXPERIMENT NO. 3

OBJECTIVE: DETERMINATION OF POLYNOMIAL USING METHOD OF LEAST


SQUARE CURVE FITTING

THEORY:
Curve fitting is a technique of finding an algebraic relationship that “best” (in least squares
sense) fits a given set of data. Unfortunately, there is no magical function (in MATLAB or
otherwise) that can give the relationship if we simply supply the data. We have to have an idea of
what kind of relationship might exist between the input data and the output data. However, if we
do not have the firm idea but have data that we trust, MATLAB can help us in exploring the best
possible fit.

MATLAB includes Basic Fitting in its Figure window’s Tools menu that lets us fit a
polynomial curve (upto 10th order) to the data on the fly. It also gives us options of displaying the
residual at the data points and computing the norm of the residuals. This can help in comparing
different fits and then selecting the one that best fits.

PROGRAM:

x=linspace(0,4*pi,10)

y=sin(x)

p=polyfit(x,y,7)

x1=linspace(0,4*pi)

y1=polyval(p,x1)

plot(x,y,'o')

hold on

plot(x1,y1)

hold off
OUTPUT:

RESULTS:

CONCLUSION:
EXPERIMENT NO. 4

OBJECTIVE: SOLUTION OF DIFFERENTIAL EQUATIONS USING 4th ORDER RUNGE-


KUTTA METHOD

THEORY:
The fourth-order Runge -Kutta (RK4) method having a truncation error of O(ℎ4 ) is one of the
most widely used methods for solving differential equations. Its algorithm is described below:

𝑦𝑘+1 = 𝑦𝑘 + 6 (𝑓𝑘1 + 2𝑓𝑘2 + 2𝑓𝑘3 + 𝑓𝑘4 ) (1)

Where
𝑓𝑘1 = 𝑓(𝑡𝑘 , 𝑦𝑘 ) (2)
ℎ ℎ
𝑓𝑘2 = 𝑓( 𝑡𝑘 + 2 , 𝑦𝑘 + 𝑓𝑘1 2 ) (3)
ℎ ℎ
𝑓𝑘3 = 𝑓( 𝑡𝑘 + 2 , 𝑦𝑘 + 𝑓𝑘2 2 ) (4)

𝑓𝑘4 = 𝑓( 𝑡𝑘 + ℎ, 𝑦𝑘 + 𝑓𝑘3 ℎ ) (5)

PROGRAM:
close all
clear all
x(1)=0;
y(1)=-2;
h=0.1;
for i=1:10
k1=h*(-2*x(i)-y(i));
k2=h*(-2*(x(i)+0.5*h)-(y(i)+0.5*k1));
k3=h*(-2*(x(i)+0.5*h)-(y(i)+0.5*k2));
k4=h*(-2*(x(i)+h)-(y(i)+k3));
y(i+1)=y(i)+1/6*(k1+k2+k3+k4);
x(i+1)=x(i)+h;
end
hold on
plot(x,y,'+-','color','blue')
xlabel('x-axis')
ylabel('y-axis')
legend('R-K 4th order method')

OUTPUT:

RESULT & DISCUSSIONS:

CONCLUSION:
EXPERIMENT NO. 5
OBJECTIVE: DETERMINATION OF TIME RESPONSE OF AN R-L-C CIRCUIT

GIVEN NUMERICAL

An R-L-C circuit has R = 180 ohms, C = 1/280 farads, L = 20 henries and an applied voltage E(t)
= 10 sin t. Assuming that no charge is present but an initial current of I ampere is flowing at t = 0
when the voltage is first applied, find q and i =dq/dt at any time t. The differential equation of
RLC series circuit is given by:
𝑑𝑞 𝑞
𝐿 𝑑 2 𝑞/𝑑𝑡 2 + 𝑅 + = 𝐸(𝑡)
𝑑𝑡 𝑐

PROGRAM:

syms q t
q = dsolve(‘20*D2q +180*Dq +280*q = 10*sin(t)’, ‘q(0)=0’)
simplify(q)
pretty(q)
i=diff(q)
pretty(i)

RESULTS:
q=
exp(-2*t)*C2+exp(-7*t)*(-C2+9/500)-9/500*cos(t)+13/500*sin(t)
>> pretty(q)
9 9 13
exp(-2 t) C2 + exp(-7 t) (-C2+500) - cos(t) + 500 sin(t)
500

>> i=diff(q)
i=
-2*exp(-2*t)*C2 – 7*exp(-7*t)*(-C2 +9/500)+ 9/500*sin(t)+13/500 *cos(t)
>> pretty(i)
13
-2 exp(-2t) C2-7 exp(-7 t)(-C2 +9/500)+9/500 sin(t)+ 500 cos(t)

RESULT:

CONCLUSION:
EXPERIMENT NO. 6
OBJECTIVE: STEP, RAMP AND IMPULSE RESPONSE OF TRANSFER FUNCTION

SOFTWARE USED: MATLAB R2009A

PROGRAM:
s= tf('s')

G=tf([8 18 32], [1 6 14 24])

figure

subplot(311), step(G)

subplot(312), step(G/s)

subplot(313), impulse(G)

OUTPUT:
EXPERIMENT NO. 7
OBJECTIVE: GENERATION OF SINGLE AND THREE PHASE SINUSOIDAL
WAVEFORM

SOFTWARE USED: MATLAB R2009A

PROGRAM:
t=0:0.002:0.04
y=sin(2*pi*50*t)
plot(t,y)
hold on
t1=0.005:0.002:0.045
y1=sin(2*pi*50*t)
plot(t1,y1)
hold on
t2=0.01:0.002:0.05
y2=sin(2*pi*50*t)
plot(t2,y2)
grid;
xlabel('time(s)')
ylabel('amplitude')
title('Three Phase Sine Waveform')

RESULT:

CONCLUSION:
EXPERIMENT NO. 8

OBJECTIVE: PWM BASED WAVEFORM GENERATION

SOFTWARE USED: MATLAB R2009A

PROGRAM:

f=1e3;
a0=0;
Ampsin=5;
t0=0;
tf=0.01;
Ts=1e-6
v=3;
AmpPWM=1
t=t0:Ts:tf
fun= Ampsin*sin(2*pi*f*t + a0);
PWM= AmpPWM*(fun>v)
clf
plot(t,fun)
hold on
plot(t,PWM, 'r')

RESULT:
SIMULINK MODEL:

RESULT:

CONCLUSION:
EXPERIMENT NO. 9
OBJECTIVE: SINGLE LINE MODELLING OF DC MOTOR

SOFTWARE USED: MATLAB R2009A

SIMULINK MODEL:

RESULT:

CONCLUSION:
EXPERIMENT NO. 10
OBJECTIVE: SINGLE PHASE UNCONTROLLED HALF WAVE RECTIFIER USING R
AND RL LOAD

SOFTWARE USED: MATLAB R2009A

SIMULINK MODEL:

Single Phase Uncontrolled Half Wave Rectifier Using R Load

RESULT:
Single Phase Uncontrolled Half Wave Rectifier Using RL Load

RESULT:

CONCLUSION:
EXPERIMENT NO. 11
OBJECTIVE: SINGLE PHASE UNCONTROLLED FULL WAVE RECTIFIER USING R
LOAD

SOFTWARE USED: MATLAB R2009A

SIMULINK MODEL:

Single Phase Uncontrolled Full Wave Rectifier Using R Load (Bridge Type)

RESULTS:
Single Phase Uncontrolled Full Wave Rectifier Using R Load (Center Tap Transformer Type)

RESULT:

CONCLUSION:
EXPERIMENT NO. 12
OBJECTIVE: THREE PHASE UNCONTROLLED FULL WAVE RECTIFIER USING R
AND RL LOAD

SOFTWARE USED: MATLAB R2009A

SIMULINK MODEL:

Three Phase Uncontrolled Full Wave Rectifier Using R Load

RESULT:
Three Phase Uncontrolled Full Wave Rectifier Using RL Load

RESULT:

CONCLUSION:

Você também pode gostar