SIGNALS-SYSTEMS LAB Manual
SIGNALS-SYSTEMS LAB Manual
SIGNALS-SYSTEMS LAB Manual
ADDITIONAL EXPERIMENTS:
12 Write a program to generate Complex Gaussian noise and find its mean, variance,
Probability Density Function (PDF) and Power Spectral Density (PSD)………….48
13 Write a program to find response of a low pass filter and high pass filter, when a speech
signal is passed through these filters………………………………………………… ……50
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 8
MATLAB INTRODUCTION
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 9
5. acos -trigonometric inverse cosine (arccosine)
6. atan -trigonometric inverse tangent (arctangent)
7. exp -exponential
8. log -natural logarithm
9. abs -absolute value 10. sqrt -square root
11. rem -remainder 12. round -round towards nearest integer
13. floor -round towards negative infinity 14. ceil -round towards positive infinity
2. Vector Functions:
Other MATLAB functions operate essentially on vectors returning a scalar value. Some of
these functions are given below.
1. max largest component : get the row in which the maximum element lies
2. min smallest component
3. length length of a vector
4. sort sort in ascending order
5. sum sum of elements
6. prod product of elements
7. median median value
8. mean mean value std standard deviation
3. Matrix Functions:
Much of MATLAB’s power comes from its matrix functions. These can be further separated into
two sub-categories. The first one consists of convenient matrix building functions, some of
which are given below.
1. eye -identity matrix
2. zeros -matrix of zeros
3. ones -matrix of ones
4. diag -extract diagonal of a matrix or create diagonal matrices
5. triu -upper triangular part of a matrix
6. tril -lower triangular part of a matrix
7. rand -randomly generated matrix
eg: diag([0.9092;0.5163;0.2661])
ans =
0.9092 0 0
0 0.5163 0
0 0 0.2661
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 10
Commands in the second sub-category of matrix functions are
1. size size of a matrix
2. det determinant of a square matrix
3. inv inverse of a matrix
4. rank rank of a matrix
5. rref reduced row echelon form
6. eig eigenvalues and eigenvectors
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 11
EXPERIMENT-1: GENERATION OF BASIC SIGNALS
Aim: To write a MATLAB program to generate sinusoidal signal, delta function, unit step function and periodic
signals.
Software Required: MATLAB
Theory
Unit Impulse
A unit impulse signal is defined by the equation (2.1)
1, n = 0
( n ) = ` (1.1)
0 , otherwise
x[ n] = C exp an (1.4)
Unit Ramp
A unit ramp function is defined in equation (2.5)
n, n 0
r( n ) = (1.5)
0 , n 0
Procedure
1. Launch MATLAB and set the desktop layout to ‘default’
2. Open a new MATLAB script from the tool bar
3. Edit the MATLAB program
4. Save and Run the script using the play button or F5 key
5. Verify the results in the figure window
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 12
6. Save the figure window using the option “save as *.jpg”
MATLAB Program
% unit impulse function %
clc;
clear all;
close all;
t=-10:1:10;
x=(t==0);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit impulse function');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit impulse discrete function');
% sinusoidal function %
% clc;
% clear all;
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 13
% close all;
t=0:0.01:2;
x=sin(2*pi*t);
figure; subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sinusoidal signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('sinusoidal sequence');
% square function %
% clc;
% clear all;
% close all;
t=0:0.01:2;
x=square(2*pi*t);
figure; subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('square signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 14
ylabel('amplitude');
title('square sequence');
% sawtooth function %
% clc;
% clear all;
% close all;
t=0:0.01:2;
x=sawtooth(2*pi*5*t);
figure; subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sawtooth signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('sawtooth sequence');
% sinc function %
% clc;
% clear all;
% close all;
t=linspace(-5,5);
x=sinc(t);
figure; subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sinc signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('sinc sequence');
% signum function %
% clc;
% clear all;
% close all;
t=-10:0.5:10;
pulse = sign(t);
figure; subplot(2,1,1);
plot(t,pulse,'g');
xlabel('time ');
ylabel('amplitude');
title('continuous signum Wave');
subplot(2,1,2);
stem(t,pulse,'r');
xlabel('time ');
ylabel('amplitude');
title('Discrete signum Sequence');
Expected Output:
Result:
Viva Questions:
1. Define signal.
2. Give few examples of DT signals.
3. Define Random signal.
4. Define power and energy signals.
5. Define odd and even signal.
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 16
EXPERMENT NO-2
ARITHMETIC OPERATIONS ON SIGNALS
APPARATUS REQUIRED:
HARDWAR: Personal
ComputerSOFTWARE:
MATLAB
Theory:
Basic Operation on Signals:
Addition: Any two signals (𝑋(𝑡) 𝑎𝑛𝑑 𝑌(𝑡) ) can be added to form a third signal (𝑍(𝑡)) and it is given
by equation (2.1)
𝑍 (𝑡 ) = 𝑋 (𝑡 ) + 𝑌 (𝑡 ) (2.1)
Multiplication: Any two signals (𝑋(𝑡) 𝑎𝑛𝑑 𝑌(𝑡) ) can be multiplied to form a third signal (𝑍(𝑡)) and
it is given by equation (2.2)
𝑍 (𝑡 ) = 𝑋 (𝑡 ) × 𝑌 (𝑡 ) (2.2)
PROCEDURE:
1. Start the MATLAB program.
6. If any error occurs in the program correct the error and run it again
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 17
MATLAB Program
clear all;
close all;
t=0:.01:1;
% generating two input signals
x1=sin(2*pi*4*t);
x2=sin(2*pi*8*t);
subplot(2,2,1);
plot(t,x1);
xlabel('time');
ylabel('amplitude');
title('signal1:sine wave of frequency 4Hz');
subplot(2,2,2);
plot(t,x2);
xlabel('time');
subplot(4,1,3);
ylabel('amplitude');
title('signal2:sine wave of frequency 8Hz');
% addition of signals
y1=x1+x2;
subplot(2,2,3);
plot(t,y1);
xlabel('time');
ylabel('amplitude');
title('resultant signal:signal1+signal2');
% multiplication of signals
y2=x1.*x2;
subplot(2,2,4);
plot(t,y2);
xlabel('time');
ylabel('amplitude');
title('resultant signal: dot product of signal1 and signal2');
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 18
Expected Result:
RESULT:
VIVA QUESTIONS:
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 19
EXPERMENT NO-3
To perform continuous-time signal operations: time shifting, time scaling, and
computation of energy and power.
1. AIM : To perform continuous-time signal operations: time shifting, time scaling, and computation of energy
and power.
APPARATUS REQUIRED:
HARDWAR: Personal
ComputerSOFTWARE:
MATLAB
Theory:
Scaling (Amplification): The amplification of the signal 𝑋 (𝑡) yields 𝑎𝑋(𝑡) and it is given by equation
(3.1)
𝑍(𝑡) = 𝑎𝑋(𝑡) (3.1)
Time shifting: If 𝑇 is a positive number, the time shifted signal, 𝑋(𝑡 − 𝑇) gets shifted to the right,
otherwise it gets shifted left.
Time shifting is as defined in equation (3.2)
𝑍(𝑡) = 𝑋(𝑡 − 𝑇) (3.2)
Time reversal or folding: The time reversal of the signal 𝑋 (𝑡) yields𝑋(−𝑡). The mirror image of the
𝑋(𝑡) about the vertical axis is 𝑋(−𝑡)and it is given by equation (3.3).
𝑍(𝑡) = 𝑋(−𝑡) (3.3)
Energy and Power signal:
A signal can be categorized into energy signal or power signal: An energy signal has a
finite energy, 0 < E < ∞. In other words, energy signals have values only in the limited
time duration. For example, a signal having only one square pulse is energy signal. A
signal that decays exponentially has finite energy, so, it is also an energy signal. The
power of an energy signal is 0, because of dividing finite energy by infinite time (or
length).
On the contrary, the power signal is not limited in time. It always exists from beginning to
end and it never ends. For example, sine wave in infinite length is power signal. Since the
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 20
energy of a power signal is infinite, it has no meaning to us. Thus, we use power
(energy per given time) for power signal, because the power of power signal is
finite, 0 < P < ∞.
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
6. If any error occurs in the program correct the error and run it again
MATLAB Program
clear all;
close all;
t=0:.01:1;
% generating two input signals
x1=sin(2*pi*4*t);
x2=sin(2*pi*8*t);
subplot(2,2,1);
plot(t,x1);
xlabel('time');
ylabel('amplitude');
title('signal1:sine wave of frequency 4Hz');
subplot(2,2,2);
plot(t,x2);
xlabel('time');
subplot(4,1,3);
ylabel('amplitude');
title('signal2:sine wave of frequency 8Hz');
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 21
% scaling of a signal1
A=10;
y3=A*x1;
figure;
subplot(2,2,1);
plot(t,x1);
xlabel('time');
ylabel('amplitude');
title('sine wave of frequency 4Hz')
subplot(2,2,2);
plot(t,y3);
xlabel('time');
ylabel('amplitude');
title('amplified input signal1 ');
% folding of a signal1
l1=length(x1);
nx=0:l1-1;
subplot(2,2,3);
plot(nx,x1);
xlabel('nx');
ylabel('amplitude');
title('sine wave of frequency 4Hz')
y4=fliplr(x1);
nf=-fliplr(nx);
subplot(2,2,4);
plot(nf,y4);
xlabel('nf');
ylabel('amplitude');
title('folded signal');
%shifting of a signal
figure;
t1=0:.01:pi;
x3=8*sin(2*pi*2*t1);
subplot(3,1,1);
plot(t1,x3);
xlabel('time t1');
ylabel('amplitude');
title('sine wave of frequency 2Hz');
subplot(3,1,2);
plot(t1+10,x3);
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 22
xlabel('t1+10');
ylabel('amplitude');
title('right shifted signal');
subplot(3,1,3);
plot(t1-10,x3);
xlabel('t1-10');
ylabel('amplitude');
title('left shifted signal');
%operations on sequences
n1=1:1:9;
s1=[1 2 3 0 5 8 0 2 4];
figure;
subplot(2,2,1);
stem(n1,s1);
xlabel('n1');
ylabel('amplitude');
title('input sequence1');
n2=-2:1:6;
s2=[1 1 2 4 6 0 5 3 6];
subplot(2,2,2);
stem(n2,s2);
xlabel('n2');
ylabel('amplitude');
title('input sequence2');
% scaling of a sequence
figure;
subplot(2,2,1);
stem(n1,s1);
xlabel('n1');
ylabel('amplitude');
title('input sequence1');
s5=4*s1;
subplot(2,2,2);
stem(n1,s5);
xlabel('n1');
ylabel('amplitude');
title('scaled sequence1');
subplot(2,2,3);
stem(n1-2,s1);
xlabel('n1');
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 23
ylabel('amplitude');
title('left shifted sequence1');
subplot(2,2,4);
stem(n1+2,s1);
xlabel('n1');
ylabel('amplitude');
title('right shifted sequence1');
% folding of a sequence
l2=length(s1);
nx1=0:l2-1;
figure;
subplot(2,1,1);
stem(nx1,s1);
xlabel('nx1');
ylabel('amplitude');
title('input sequence1');
s6=fliplr(s1);
nf2=-fliplr(nx1);
subplot(2,1,2);
stem(nf2,s6);
xlabel('nf2');
ylabel('amplitude');
title('folded sequence1');
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 24
Expected Result:
RESULT:
VIVA QUESTIONS:
1. What is the difference between power signal and energy signal in terms of energy and power?
2. How can you differentiate signal and wave?
3. What is the basic difference between amplitude and magnitude?
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 25
EXPERIMENT-4: SIGNAL SYNTHESIS USING FOURIER SERIES
AIM: - To write a MATLAB program to synthesize periodic signals using Fourier series.
THEORY:-
According to the important theorem formulated by the French mathematician Jean Baptiste
Joseph Baron Fourier, any periodic function, no matter how trivial or complex, can be expressed
in terms of converging series of combinations of sines and/or cosines, known as Fourier series.
Therefore, any periodic signal is a sum of discrete sinusoidal components
The Fourier theorem is fairly general and also applies to periodic functions that have
discontinuities and cannot be represented by a single analytical expression. For a periodic
function f(x), provided that the following conditions are satisfied (Dirichlet conditions):
(a) f(x) is defined and single-valued except (perhaps) at a finite number in (-T, T),
(b) f(x) is periodic outside (-T, T) with period 2T,
(c) f(x) and f΄(x) are piecewise continuous in (-T, T), then f(x) can be expressed by the
following series:
where
Procedure
1. Launch MATLAB and set the desktop layout to ‘default’
2. Open a new MATLAB script from the tool bar
3. Edit the MATLAB program
4. Save and Run the script using the play button or F5 key
5. Verify the results in the figure window
6. Save the figure window using the option “save as *.jpg”
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 26
MATLAB Program
clc;
clear all;
close all;
% Function
f = (3.*cos(k));
% plotting function
subplot(2,2,1);
plot(k*(180/pi),f);
title('original signal');
grid on;
% plotting coefficients
% real
v = -16:1:16; % Number of fourier series coefficients
subplot(2,2,2);
plot(v, real(Cn));
grid on;
xlim([-16, 16]);
title('real coefficients ');
%imaginary
v = -16:1:16; % Number of fourier series coefficients
subplot(2,2,3);
plot(v, imag(Cn));
grid on;
title('imaginary coefficients ');
% plotting reconstruction
subplot(2,2,4);
plot(k*(180/pi),S);
title('reconstructed signal');
grid on;
Expected Output:
Result:
Vi va Questions:
1. Define Gibb’s Phenomenon?
2. What are Dirichlet’s condition?
3. Why do we do Fourier Transform?
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 28
EXPERIMENT-5: FINDING TFS AND EFS COEFFICIENTS
AIM: - Write a program to find the trigonometric & exponential Fourier series coefficients of a
rectangular periodic signal. Reconstruct the signal by combining the Fourier series coefficients with
appropriate weightages - Plot the discrete spectrum of the signal
THEORY:-
Theory: to compute the trigonometric fourier series coefficients of a periodic square wave time signal that has
a value of 2 from time 0 to 3 and a value of -12 from time 3 to 6. It then repeats itself. I am trying to calculate
in MATLAB the fourier series coefficients of this time signal and am having trouble on where to begin.
Procedure
1. Launch MATLAB and set the desktop layout to ‘default’
2. Open a new MATLAB script from the tool bar
3. Edit the MATLAB program
4. Save and Run the script using the play button or F5 key
5. Verify the results in the figure window
6. Save the figure window using the option “save as *.jpg”
MATLAB Program
clear all
close all
clc
fs=10;
T=2;
w0=2*pi/T;
k=0:1/fs:5-1/fs;
%k=0:1/fs:10-1/fs;
y=square(w0*k,50);
figure
plot(k,y)
xlabel('t (seconds)'); ylabel('y(t)');
syms t
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 29
N=10;
n=1:N;
a0=(2/T)*(int(1,t,0,1)+int(-1,t,1,2));
an=(2/T)*(int(1*cos(n*w0*t),t,0,1)+int(-
1*cos(n*w0*t),t,1,2));
bn=(2/T)*(int(1*sin(n*w0*t),t,0,1)+int(-
1*sin(n*w0*t),t,1,2));
F=a0/2;
for i=1:N
F=F+an(i)*cos(i*w0*k)+bn(i)*sin(i*w0*k);
end
figure
hold on
plot(k,y)
plot(k,F,'r')
xlabel('t (seconds)'); ylabel('y(t)');
title('Truncated Trigonometric Fourier Series');
hold off
grid on
mag=abs(F);
figure;
stem(k,mag)
xlabel('time')
ylabel('Magnitude')
title('Magnitude response')
phase=angle(F);
figure
plot(k,phase)
xlabel('time')
ylabel('Phase')
title('Phase response')
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 30
Expected Output:
Result:
Viva Questions:
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 31
EXPERIMENT-6: FOURIER TRANSFORM
AIM: -To write a MATLAB program to find Fourier Transform and Inverse Fourier Transform of a given
signal and to plot its Magnitude and Phase Spectra.
THEORY:-
Fourier Transform:
The Fourier transform as follows. Suppose that ƒ is a function which is zero outside of some interval [−L/2, L/2].
Then for any T ≥ L we may expand ƒ in a Fourier series on the interval [−T/2,T/2], where the "amount" of the
wave e2πinx/T in the Fourier series of ƒ is given by By definition Fourier Transform of signal f(x) is defined as
− jt
F ( ) = f (t ) e
−
dt
Procedure
1. Launch MATLAB and set the desktop layout to ‘default’
2. Open a new MATLAB script from the tool bar
3. Edit the MATLAB program
4. Save and Run the script using the play button or F5 key
5. Verify the results in the figure window
6. Save the figure window using the option “save as *.jpg”
Program:
clc;
clear all;
close all;
syms x a b
X = input('Fourier Transform of a function ....:: ');
disp('is ......:: ');
Xf = fourier(X)
fs=1000;
N=1024; % length over which plot of signal and spectrum are needed
t=[0:N-1]*(1/fs);
% input signal
y=0.8*cos(2*pi*100*t);
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 32
subplot(3,1,1);
plot(t,y);
axis([0 0.05 -1 1]);
grid;
xlabel('t');
ylabel('amplitude');
title('input signal');
% magnitude spectrum
x1=fft(y);
k=0:N-1;
Xmag=abs(x1);
subplot(3,1,2);
plot(k,Xmag);
grid;
xlabel('k');
ylabel('amplitude');
title('magnitude of fft signal')
% phase spectrum
Xphase=angle(x1)*(180/pi);
subplot(3,1,3);
plot(k,Xphase);
grid;
xlabel('k');
ylabel('angle in degrees');
title('phase of fft signal');
% % ******************* % %
% clc;
% close all;
% clear all;
x=input('enter the sequence');
N=length(x);
n=0:1:N-1;
y=fft(x,1024);
figure; subplot(3,1,1);
stem(n,x);
title('input sequence');
xlabel('time ');
ylabel('amplitude ');
% magnitude spectrum
Xmag=abs(y);
k=1:1024;
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 33
subplot(3,1,2);
plot(k,Xmag);
grid;
xlabel('k');
ylabel('amplitude');
title('magnitude of fft signal')
% phase spectrum
Xphase=angle(y)*(180/pi);
subplot(3,1,3);
plot(k,Xphase);
grid;
xlabel('k');
ylabel('angle in degrees');
title('phase of fft signal');
Expected Output:
Result:
Viva Questions:
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 34
EXPERIMENT NO-7
AIM: To compute and plot the impulse response and pole-zero diagram of transfer function using
Laplace transform.
APPARATUS REQUIRED:
SOFTWARE: MATLAB
Theory : A Transfer Function is the ratio of the output of a system to the input of a system, in
the Laplace domain considering its initial conditions to be zero. If we have an input function of
X(s), and an output function Y(s), we define the transfer function H(s) to be
Given a continuous-time transfer function in the Laplace domain, H(s) or a discrete-time one
in the Z-domain, H(z), a zero is any value of s or z such that the transfer function is zero,
and a pole is any value of s or z such that the transfer function is infinite
Zeros:1. The value(s) for z where the numerator of the transfer function equals zero.The
complex frequencies that make the overall gain of the filter transfer function zero.
Poles: 1. The value(s) for z where the denominator of the transfer function equals zero
The complex frequencies that make the overall gain of the filter transfer function infinite.
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 35
6. If any error occurs in the program correct the error and run it again
PROGRAM:
clc;
clear all;
close all;
num=input('enter numerator co-efficients');
den=input('enter denominator co-efficients');
h= tf2zp(num,den)
h=tf(num,den);
poles=roots(den);
zeros=roots(num);
sgrid;
pzmap(h);
grid on;
title('locating poles of zeros on s-plane');
%locating poles &zeros on z-plane%
clc;
clear all;
close all;
num=input('enter numerator coefficient');
den=input('enter denominator coefficient');
p=roots(den);
z=roots(num);
zplane(p,z);
grid;
title('locating poler and zeros on s-plane');
subplot(2,1,1)
step(h)
subplot(2,1,2)
impulse(h)
OUTPUT:-
locating poles of zero on s-plane
enter numerator coefficient[1 2 3]
enter denominator coefficient[7 6 5]
Expected output:
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 36
Expected out put:
Result:
Viva Questions:
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 37
EXPERIMENT-8: LINEAR CONVOLUTION OF SIGNALS
Aim: To write a MATLAB program to compute linear convolution of continous time signals and
discrete time sequences.
Theory:
Convolution is a mathematical tool to combining two signals to form a third signal. Therefore,
in signals and systems, the convolution is very important because it relates the input signal and
the impulse response of the system to produce the output signal from the system. In other
words, the convolution is used to express the input and output relationship of an LTI system.
Consider a continuous-time LTI system which is relaxed at t = 0, i.e., initially,no input is
applied to it. Now, if the impulse signal [δ(t)] is input to the system, then output of the system
is called the impulse response h(t) of the system and is given by,
h(t)=T[δ(t)]
As any arbitrary signal x(t) can be represented as x(t)=∫∞−∞x(τ)δ(t−τ)dτ
Then, the output of the system corresponding to x(t) is given by,
y(t)=T[x(t)]
Therefore, the convolution of two continuous-time signals x(t) and h(t) is represented as,
y(t)=x(t)∗h(t)=∫∞−∞x(τ)h(t−τ)dτ
Procedure
1. Launch MATLAB and set the desktop layout to ‘default’
2. Open a new MATLAB script from the tool bar
3. Edit the MATLAB program
4. Save and Run the script using the play button or F5 key
5. Verify the results in the figure window
6. Save the figure window using the option “save as *.jpg”
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 38
MATLAB Program
subplot(2,2,1);
stem(x);
title('Sequence 1');
subplot(2,2,2);
stem(h);
title('Sequence 2');
o=zeros(1,length(x)+length(h)-1);
for m=1:length(x),
for n=1:length(h),
y(m,n)=x(m)*h(n);
end;
end;
for n=1:length(x)+length(h)-1,
for i=1:length(x),
for j=1:length(h),
if(i+j==n+1)
o(n)=o(n) + y(i,j)
end;
end;
end;
end;
subplot(2,2,3);
stem(o);
title('output without using function');
o1 = conv(x,h)
subplot(2,2,4);
stem(o1);
title('output by using function');
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 39
Expected Output:
Result:
VIVA QUESTIONS:
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 40
EXPERIMENT-9: CORRELATION OF SIGNALS
Aim: To compute auto correlation and cross correlation between signals and Sequences using
MATLAB.
Procedure
1. Launch MATLAB and set the desktop layout to ‘default’
2. Open a new MATLAB script from the tool bar
3. Edit the MATLAB program
5. Save and Run the script using the play button or F5 key
6. Enter the inputs from the command window
7. Verify the results in the command and figure windows
8. Save the figure window using the option “save as *.jpg”
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 41
MATLAB Program
clc;
close all;
clear all;
x=input('enter input sequence');
h=input('enter the impulse sequence');
subplot(2,2,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input sequence');
subplot(2,2,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('impulse signal');
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 42
title('input signal');
subplot(2,2,2);
plot(t,h1);
xlabel('t');
ylabel('h1(t)');
title('impulse signal');
% cross correlation
subplot(2,2,3);
z1=xcorr(x1,h1);
plot(z1);
xlabel('t');
ylabel('z1(t)');
title('cross correlation ');
% auto correlation
subplot(2,2,4);
z2=xcorr(x1,x1);
plot(z2);
xlabel('t');
ylabel('z2(t)');
title('auto correlation ');
Expected Results
Result:
VIVA QUESTIONS:
1. What is autocorrelation?
2. What is the convolution of a signal with an impulse?
3. What is the commutative property?
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 43
EXPERIMENT-10: SAMPLING THEOREM
Theory
A band limited signal of finite energy which has no frequency components higher than W hertz
is completely recovered from the knowledge of its samples taken at the rate of 2W samples per
second, where W = 2fm. These statements can be combinedly stated as A bandlimited signal x(t)
with X(j ω) = 0 for |ω| > ωm is uniquely determined from its samples x(nT), if the sampling
frequency fs ≥ 2fm, ie., sampling frequency must be atleast twice the highest frequency present
in the signal.
Procedure
1. Launch MATLAB and set the desktop layout to ‘default’
2. Open a new MATLAB script from the tool bar
3. Edit the MATLAB program
4. Save and Run the script using the play button or F5 key
5. Verify the results in the figure window
6. Save the figure window using the option “save as *.jpg”
MATLAB Program
clc;
clear all;
close all;
t = 0:0.01:2;
msg = sin(2*pi*t);
k = 2*Fs/Fm;
step = ceil(201/k);
samp_msg = [];
for i = 1:201,
if (mod(i,step) == 0)
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 44
samp_msg = [samp_msg,msg(i)];
else
samp_msg = [samp_msg,zeros(1)];
end;
end;
subplot(2,1,1);
plot(msg);
xlabel('---> Time');
ylabel('---> Amplitude');
title('Msg signal');
subplot(2,1,2);
stem(samp_msg);
xlabel('---> Time');
ylabel('---> Amplitude');
if Fs < 2*Fm
title('Under Sampling');
else if Fs == 2*Fm
title('Critical Sampling');
else
title('Over Sampling');
end;
end;
Expected Output:
Result:
Viva Questions:
3. Define aliasing.
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 45
EXPERIMENT-11: POLE-ZERO DIAGRAM OF TRANSFER FUCTION USING Z-TRANSFORM
Aim: To write a MATLAB program to plot Pole-Zero diagram of given transfer function using Z-Transform.
Theory
Introduction to Poles and Zeros of the Z-Transform
It is quite difficult to qualitatively analyze the Laplace transform and Z-transform, since mappings of their
magnitude and phase or real part and imaginary part result in multiple mappings of 2-dimensional surfaces
in 3-dimensional space. For this reason, it is very common to examine a plot of a transfer function's poles
and zeros to try to gain a qualitative idea of what a system does.Once the Z-transform of a system has been
determined, one can use the information contained in function's polynomials to graphically represent the
function and easily observe many defining characteristics. The Z-transform will have the below structure,
based on Rational Functions
X(z)=P(z)/Q(z)
The two polynomials, P(z) and Q(z), allow us to find the poles and zeros of the Z- Transform.
Definition: zeros :
1. The value(s) for z where P(z)=0.
2. The complex frequencies that make the overall gain of the filter transfer function zero.
Definition: poles:
1. The value(s) for z where Q(z)=0.
2. The complex frequencies that make the overall gain of the filter transfer function infinite.
Procedure
1. Launch MATLAB and set the desktop layout to ‘default’
2. Open a new MATLAB script from the tool bar
3. Edit the MATLAB program
4. Save and Run the script using the play button or F5 key
5. Verify the results in the figure window
6. Save the figure window using the option “save as *.jpg”
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 46
MATLAB Program
clc;
clear all;
close all;
num=input('enter numerator coefficient');
den=input('enter denominator coefficient');
p=roots(den);
z=roots(num);
zplane(p,z);
grid;
title('locating poler and zeros on s-plane');
subplot(2,1,1)
step(h)
subplot(2,1,2)
impulse(h)
Expected Output:
Result:
Viva Questions:
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 47
ADDITIONAL EXPERIMENTS:
EXPERIMENT-12: Write a program to generate Complex Gaussian noise and find its mean,
Variance, Probability Density Function (PDF) and Power Spectral Density (PSD).
Aim: Write the program for generation of Gaussian noise and computation of its mean, mean square
value, standard deviation, variance, and skewness.
Software Required: Matlab software.
Theory:
Gaussian noise is statistical noise that has a probability density function (abbreviated pdf) of the
normal distribution (also known as Gaussian distribution). In other words, the values the noise can take
on are Gaussian-distributed. It is most commonly used as additive white noise to yield additive white
Gaussian noise (AWGN).Gaussian noise is properly defined as the noise with a Gaussian amplitude
distribution. says nothing of the correlation of the noise in time or of the spectral density of the noise.
Labeling Gaussian noise as 'white' describes the correlation of the noise. It is necessary to use the term
"white Gaussian noise" to be correct. Gaussian noise is sometimes misunderstood to be white Gaussian
noise, but this is not the case.
MATLAB Program
clc;
clear all;
close all;
%generates a set of 2000 samples of Gaussian distributed random
numbers
x=randn(1,2000);
%plot the joint distribution of both the sets using dot.
subplot(211)
plot(x,'.');
title('scatter plot of gaussian distributed random numbers');
ymu=mean(x)
ymsq=sum(x.^2)/length(x)
ysigma=std(x)
yvar=var(x)
yskew=skewness(x)
p=normpdf(x,ymu,ysigma);
subplot(212);
stem(x,p);
title(' gaussian distribution');
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 48
Expected Output:
Result:
VIVA QUESTIONS:-
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 49
EXPERIMENT-13: Write a program to find response of a low pass filter and high pass filter,
when a speech signal is passed through these filters. Aim: To find response of a low pass filter
and high pass filter, when a speech signal is passed through these filters
Aim: Write a program to find response of a low pass filter and high pass filter, when a speech
signal is passed through these filters. Aim: To find response of a low pass filter and high pass
filter, when a speech signal is passed through these filters.
You can change the stopband attenuation, the transition band steepness, and the type of impulse
response of the filter.
[y,d] = lowpass(___) also returns the digitalFilter object d used to filter the input.
lowpass(___) with no output arguments plots the input signal and overlays the filtered signal
Program :
% Read standard sample tune that ships with MATLAB.
[dataIn, Fs] = audioread('guitartune.wav');
% Filter the signal
fc = 800; % Make higher to hear higher frequencies.
% Design a Butterworth filter.
[b, a] = butter(6,fc/(Fs/2));
freqz(b,a)
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 50
% Apply the Butterworth filter.
filteredSignal = filter(b, a, dataIn);
% Play the sound.
player = audioplayer(filteredSignal, Fs);
play(player);
Expected output:
Result:
Viva Questions:
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 51