SNS Final - 1-Merged
SNS Final - 1-Merged
LAB MANUAL
For the course
Instructor Name:__________________________________
Student Name:____________________________________
Roll No: Batch:___________________
Semester: Year:____________________
Laboratory Session Signals & Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
LAB MANUAL
For the course
Approved By
Roll No. Rubric Rubric Rubric Rubric Rubric Rubric OEL/PBL Final LAB Attendance Final weighted Score for
based based based based based based Rubric Rubric Percentage MIS System
Lab I Lab II Lab III Lab IV Lab V Lab VI Score Score [10(A)+10(B)+5(C)]/25
A B C Round to next higher
multiple of 5
Note: All Rubric Scores must be in the next higher multiple of 5 for correct entry in MIS system.
Laboratory Session Signals & Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
CONTENTS
Objective:
To get introduced with the basic features and functions of Oscilloscope, function generator
and DC power supply.
Theory:
Introduction to Oscilloscope:
It is an instrument which is used to display the waveform or time vs value curves of electrical signals.
1
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
a) Basic Purpose
It is an instrument which is used to display the waveform or time vs value curves of electrical
signals.
Setting Up Connections;
Before using the Oscilloscope, the proper grounding is very important for safety purpose, not for
the user but also for testing the integrated circuits (ICs), necessary because if a high voltage
contacts with any grounded part, the current travels through the grounding path to earth, rather
harming the user.
2. Types of Waves
3. Duty Cycle
The term duty cycle describes the proportion of 'on' time to the total fundamental time. For 90%
it is ‘ON’ time and for 10% it is for ‘OFF’ time. It is only for square waves.
Duty Cycle
Laboratory Session Signals &Systems (EE-231)
Department of Electrical Engineering NED University of Engineering and Technology
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
LAB#1
Activity: Add two waves of 50Hz and 100Hz.
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Objective:
Theory:
Defining Variables
[Note: Semicolon’s are not used if user want to display value on command window.]
>> a = 2
a=
[Note: Variable names should start from letter, MATLAB default variables cannot be used such as pi,
i, ans, NaN etc.]
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Plotting Command
Observation:
• Contour Plots
Observation:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
• Surface Plots
>> surf(x,y,z), xlabel('x'), ylabel('y'), zlabel('-(x^2+y^2)'); % Develop 3-D surface
>> surfc(x,y,z), xlabel('x'), ylabel('y'), zlabel('-(x^2+y^2)'); % Develop 3-D surface with their contour on xy plane
Code 04: Contour Plot from 3D information using MATLAB
Observation:
Observation:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Fig. 2.6 illustrates the GUI (Graphical User Interface) of MATLAB plotting. GUI helps to
customize the plotted figures; labels, orientation, colours and many of its insights.
GUI
Fig.2.7 depicts the menu bar and tool bar of GUI of plotting figures. Below Following fig. 2.8 shows the
options of menu bar. They are very helpful to copy image with high quality, label axis, Zoom In-Out, scaling
etc. On a side, tool bar has shortcut keys like 3D rotation, coloring, Zoom In-Out etc.
File Menu Edit Menu Insert Menu Tools Menu View Menu
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Activity 1:
For given Matrices:
CODE:
A = [2 9 0 0; 0 4 1 4;7 5 5 1; 7 8 7 4]
b = [ -1;6;0;9 ]
a = [ 3 -2 4 -5]
disp("A.b:")
disp( A*b )
disp("a+4:")
disp( a+4 )
disp("b.a:")
disp( b*a )
try
disp ("a.bT:")
disp ( a*b' )
catch
disp ( "Cannot perform 'a.bT'")
end
try
disp ("A.aT:")
disp ( A*a' )
catch
disp ( "Cannot perform 'A.aT'")
end
COMMAND WINDOW OUTPUT:
A =
2 9 0 0
0 4 1 4
7 5 5 1
7 8 7 4
b =
-1
6
0
9
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
a =
3 -2 4 -5
A.b:
52
60
32
77
a+4:
7 2 8 -1
b.a:
-3 2 -4 5
18 -12 24 -30
0 0 0 0
27 -18 36 -45
a.bT:
Cannot perform 'a.bT'
A.aT:
-12
-24
26
13
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Object:
Plotting of Basic Signals in MATLAB & familiarization with procedural
programming in MATLAB
Theory:
y = 0;
for k = 1:5
y = y + k;
end
y
y = 0;
for k = 2:2:8
y = y + k;
end
y
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
for k = 1:5
y(k)=k^2;
end
y
Nested Loops:
for j = 1:3
for k = 1:3
T(j,k) = j*k;
end
end
T
Plot this equation using ‘for loop’ for values of x from -10 to 10.
Hint: Use a for loop to calculate and store x and y values in one-dimensional arrays
for i = 1:21
x(i) = -10 +(i-1);
y(i) = 2^(0.4*x(i)) + 5;end
After running these lines of code, two one-dimensional arrays, x and y, have been
created, each with 21 elements
The stored arrays can be plotted with the command: plot(x,y)
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Any two one-dimensional arrays can be plotted, as long as they are exactly the same
size
The plot will be created in a new window
Now, add x label, y label and set x limit and y limit yourself.
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Activity: Acquire 1000 points of cosine wave having frequency of 60Hz using for loop. Plot the Signal.
Observation
Conclusion
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Objective:
Theory
• Imaginary Power
• Real Power
• Complex Power
The plot is in the form of Sine and Cosine wave curves. When we plot imaginary values, cycles are to
be appeared, negative cycles classified them into decay of exponential plot as they are dealt in
negative signs. Similarly, for the oscillatory exponential signal these cycles are positive cycles as they
are dealt in positive sign. They just differ by signs which kept them different and classified into Decay
and Oscillatory Exponential cycles when they are imaginary values. But these are not useful to us
because they cannot be described in our physical world.
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
OBSERVATION
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
OBSERVATION
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Run the following codes on MATLAB and attach the output and comment on it.
OBSERVATION
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Sample Model
OBSERVATION
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
CONCLUSION
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Objective:
a) Statement
“Any periodic signal can be expressed as a linear combination of sinusoids or infinite sum of
sines and cosines”
b) Analysis Equation
The Fourier series can be analyzed in trigonometric form, compact trigonometric form and
exponential form. Where, “a0” is the zero harmonic (i.e. DC Offset at zeroth harmonic) and
“n” is no. of harmonics.
i. Trigonometric Form
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
T=pi; w=2;
syms t
a0=(1/T)*(int(exp(-t/2),t,0,T)); x=a0;
d = -2*pi:0.01*pi/2:2*pi;
%d=(-d);
for n=1:16
an=(2/T)*(int(exp(t/2)*cos(2*t*n),t,0,T));
bn=(2/T)*(int(exp(t/2)*sin(2*t*n),t,0,T)); x=x+(an*cos(2*n*d))+(bn*sin(2*n*d));
subplot(4,4,n), plot(d,x),xlabel('t'),ylabel('x(t)'); cn(n+1)=sqrt((an^2)+(bn^2));
thetha(n+1)=((atan(-bn/an))*(180/pi)); temp(n+1)=n;
end cn(1)=a0; thetha(1)=0; temp(1)=0;
%plot(-d,x),xlabel('t'),ylabel('x(-t)'),title('x(t)=\ite^{-t/2}');
%subplot(2,1,1),
%stem(temp,cn),xlim([- 1,10]),ylim([0,0.7]),xlabel('n'),ylabel('Cn'),title('Amplitude Spectrum');
%subplot(2,1,2),
%stem(temp,thetha),xlim([-1,10]),xlabel('n'),ylabel('Thetha(n)'),title('Phase Spectrum');
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
T=pi;
w=2;
syms t
a0=(1/T)*(int(exp(-t/2),t,0,T));
x=a0;
d = -2*pi:0.01*pi/2:2*pi;
%d=(-d);
for n=1:16
an=(2/T)*(int(exp(t/2)*cos(2*t*n),t,0,T));
bn=(2/T)*(int(exp(t/2)*sin(2*t*n),t,0,T));
x=x+(an*cos(2*n*d))+(bn*sin(2*n*d));
subplot(4,4,n), plot(d,x),xlabel('t'),ylabel('x(t)');
cn(n+1)=sqrt((an^2)+(bn^2));
thetha(n+1)=((atan(-bn/an))*(180/pi));
temp(n+1)=n;
end
cn(1)=a0;
thetha(1)=0;
temp(1)=0;
%plot(-d,x),xlabel('t'),ylabel('x(-t)'),title('x(t)=\ite^{-t/2}');
%subplot(2,1,1),
%stem(temp,cn),xlim([-
1,10]),ylim([0,0.7]),xlabel('n'),ylabel('Cn'),title('Amplitude Spectrum');
%subplot(2,1,2),
%stem(temp,thetha),xlim([-1,10]),xlabel('n'),ylabel('Thetha(n)'),title('Phase
Spectrum');
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Observations:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
CONCLUSION
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
b. The signal y(t) can be obtained by time reversal of x(t) shown below. Use this fact to obtain
the Fourier series for y(t) from the results in your textbook “Example 6.1”. Verify that the
Fourier series thus obtained is identical to that found in part (a).
Code:
T=pi;
w=2;
syms t
a0=(1/T)*(int(exp(-t/2),t,0,T));
x=a0;
d = -2*pi:0.01*pi/2:2*pi;
d=(-d);
for n=1:16
an=(2/T)*(int(exp(-t/2)*cos(2*t*n),t,0,T));
bn=(2/T)*(int(exp(-t/2)*sin(2*t*n),t,0,T));
x=x+(an*cos(2*n*d))+(bn*sin(2*n*d));
subplot(4,4,n), plot(-d,x),xlabel('t'),ylabel('x(t)');
cn(n+1)=sqrt((an^2)+(bn^2));
thetha(n+1)=((atan(-bn/an))*(180/pi));
temp(n+1)=n;
end
cn(1)=a0;
thetha(1)=0;
temp(1)=0;
%plot(-d,x),xlabel('t'),ylabel('x(-t)'),title('x(t)=\ite^{-t/2}');
%subplot(2,1,1),
%stem(temp,cn),xlim([-
1,10]),ylim([0,0.7]),xlabel('n'),ylabel('Cn'),title('Amplitude Spectrum');
%subplot(2,1,2),
%stem(temp,thetha),xlim([-1,10]),xlabel('n'),ylabel('Thetha(n)'),title('Phase
Spectrum');
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Output:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
c. Show that, in general, time reversal of a periodic signal does not affect the amplitude
spectrum, and the phase spectrum is also unchanged except for the change of sign.
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Objective:
To study different types of signal using MATLAB
THEORY
Singularity Functions:
Singularity functions are discontinuous functions, or their derivatives are discontinuous.
A singularity is a point at which a function does not possess a derivative. In other words,
a singularity function is discontinuous at its singular points.
Singularity functions are a class of discontinuous functions that contain singularities, i.e.
they contain points in which their derivatives do not exist. In other words, a singularity
function is discontinuous at its singular points.
Elementary Signals:
The elementary signals are used for analysis of systems. Such signals are,
1. Step
2. Impulse
3. Ramp
4. Exponential
5. Sinusoidal
3. Ramp Sequence:
The ramp function is a unary real function which is 0 for negative inputs; output equals
input for non-negative inputs.
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
5. Rect Function:
The Rect Function is a function which produces a rectangular-shaped pulse with a width
of 1 centered at t = 0. The Rect function pulse also has a height of 1. A rect function cn
be written in the form :
𝑡−𝑋
Rect ( 𝑌 )
where the pulse is centered at X and has width Y.
6. Signum Function:
The sign function or signum function is an odd mathematical function that extracts
the sign of a real number.
The signum function of a real number x is defined as follows:
Alternatively,
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
7. Square Wave:
A square wave is a non-sinusoidal periodic waveform in which the amplitude
alternates at a steady frequency between fixed minimum and maximum values, with
the same duration at minimum and maximum.
It can be defined as simply the sign function of a sinusoid:
8. Sawtooth wave:
The sawtooth wave, called the "castle rim function" is the periodic function given by
1) Unit Impulse:
2) Unit Step:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
3) Ramp:
4) Sinc:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
7) Square:
8) Sawtooth:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Objective:
Theory:
Time Constant ( τ )
The delay in the time delay circuits is generally known as the Time Constant of the
circuit and is defined as;
“The time required for the response to decay to a factor of 1/e or ≈36.8% of its initial value,
conversely, the time required to charge the capacitor from an initial voltage of zero to ≈63.2%
of the value of an applied source voltage”
The time constant of a circuit mainly depends upon the reactive components either
capacitive or inductive connected to it and is a measurement of the response time with
the unit of Tau (τ).
R=1.8k Ω
C=1µF
VS = 5Vpp
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
This is the response of the RC circuit to abrupt change of source when the capacitor was initially
charged to some voltage Vo at t – instant. Since the voltage of a capacitor cannot change
abruptly, therefore
Objective:
Theory:
TIME CONSTANT
In an RC circuit, the product of Resistance and capacitance of the circuit is called RC time
constant (). It has a good contribution in the time delay of RC circuits. Mathematically;
Where R is the resistance of the circuit and C is the capacitance of the circuit.
The value of time constant is measured in seconds. It is the value of time that shows how
much a capacitor will be charged and discharged. One must note that five times the time
constant (tau) refers to the state when a capacitor is either fully charged or fully
discharged depending on whether an RC circuit is charging or discharging.
RESPONSE OF SYSTEM:
I. Initial conditions at t = 0
II. Input of system at t ≥0
The total response of system is sum of two components.
TYPES OF RESPONSE:
Zero-state response:
Response that results from input x(t) for t ≥ 0, with initial conditions (at t = 0)
are zero.
TOTALRESPONSE
Activity 3: Observe Zero-Input response using Simulink’s scope element and observe
values as mentioned in each column below:
Activity 1: Simulate RL Circuit using Simulink. Assume the values of each element
R=100 , L=10 , Time Constant=0.1 sec
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Activity 2: Calculate Time Constant and draw the graph of current through inductor
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Activity 3: Observe Zero-Input response using Simulink’s scope element and observe values
of parameters mentioned in the table below:
Objective:
Time Domain Analysis of SECOND ORDER Circuit – To simulate, understand, and validate
Zero-Input Response of RLC Series Circuit
Theory:
Circuits that include an inductor, capacitor, and resistor connected in series or in parallel are
second-order circuits.
If you can use a second-order differential equation to describe the circuit you’re looking at, then
you’re dealing with a second-order circuit.
TIME CONSTANT
In an RC circuit, the product of Resistance and capacitance of the circuit is called RC time constant
or (). It has a good contribution in the time delay of RC circuits.
Mathematically; for RC Circuit,
𝜏 = 𝑅𝐶
For RL circuit,
𝑅
𝜏=
𝐿
Where R is the resistance of the circuit, C is the capacitance, and L is inductance of the circuit.
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Activity:
Construct a series RLC circuit using Simulink with R = 3 Ohms, L=1 H, C=1.5 F. Visualize the response of
circuit as voltage across capacitor and current through the circuit.
Circuit:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Current:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Voltage:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Simulate zero input response of RLC Series circuit, given Vc (0) = y (0) = 5V and visualize the
response as current through inductor
Circuit:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Current:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Voltage:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Activity 2:
Simulate zero input response of RLC Series circuit, given Vc (0) = y (0) = 5V and visualize the
response as current through inductor
Circuit:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Current:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Voltage:
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Objective:
Theory:
CONVOLUTION
Convolution between two continuous time signals 𝑥(𝑡) and ℎ(𝑡) is defined as:
∞
𝑥(𝑡)ℎ(𝑡) = ∫ 𝑥(𝜏)ℎ(𝑡 − 𝜏)𝑑𝜏
−∞
Where, τ is a dummy variable for integration.
Activity 1: Perform Continuous Time Convolution using Matlab and draw graphs of signals and
convolutional integral using Matlab for following signal,
Matlab Script:
t0=0;
tf=12;
N=5000;
dt=(tf-t0)/N;
t=t0:dt:tf;
for k=1:length(t)
if t(k) < 2
x(k)=0;
else if t(k) < 4
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
x(k)= 0.05;
else
x(k)=0;
end
end
end
h=exp(-3*t);
y=conv(x,h);
subplot(3,1,1), plot(t,x,'r')
axis([t0,tf,0,0.1])
ylabel('x(t)'), xlabel('t')
subplot(3,1,2), plot(t,h,'r')
axis([t0,tf,0,2])
ylabel('h(t)'), xlabel('t')
subplot(3,1,3), plot(t,y(1:length(t)),'r')
axis([t0,tf,0,10])
ylabel('y(t)'),xlabel('t')
OUTCOME
LAB#9
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Activity 2: Perform convolution analytically and draw graphs. Compare the graphs drawn in matlab to
the manual graph of analytically derived C.I.
Laboratory Session Signals &Systems (EE-231)
Department of Electrical Engineering NED University of Engineering and Technology
Laboratory Session Signals &Systems (EE-232)
Department of Electrical Engineering NED University of Engineering and Technology
Objective:
Theory:
An ordinary differential equation (ODE) is defined as the equation that contains one or more functions of
one independent variable and its derivatives.
𝑑𝑦(𝑡)
𝑑𝑡
+ 𝑦(𝑡) = 𝑡 , where y(t) is function of independent variable t
The solution of such equation contains two parts.
1) Homogeneous Solution, which is computed with assumption that Input to the system is Zero.
2) Particular Solution, which is calculated assuming Zero Initial Conditions.
3) The total solution is linear sum of both homogeneous solution and particular solution as given
below:
LAB#10 Activity:1