SIGNALS-SYSTEMS LAB Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

INDEX

S.No Description Page No.

1 To generate sinusoidal signal, delta function, unit step function ………....12


and periodic signals.
2 To perform arithmetic operations: addition, subtraction and multiplication
on continuous-time signals……………………………………………………… ..17
3 To perform continuous-time signal operations: time shifting, time
scaling, and computation of energy and power……………………………………20

4 To synthesize periodic signals using Fourier series………………………………..26

5 To write a program to find the trigonometric and exponential Fourier series


coefficientsof a periodic rectangular signal. Plot the discrete spectrum of the
signal……………………………………………………………………………….29

6 To Find Fourier Transform and Inverse Fourier Transform of a given signal


and plot its Magnitude and Phase Spectra………………………………………….32

7 To compute and plot the impulse response and pole-zero diagram of


transfer functionusing Laplace transform…………………………………………..35

8 To compute the linear convolution of continuous-time signals and


verify its properties…………………………………………………………………38

9 To compute auto correlation and cross correlation between continuous-time signals


and verify its properties………………………………………………………… …41

10 To verify the sampling theorem……………………………………………………44

11 To compute and plot the impulse response and pole-zero diagram of


transfer functionusing Z-transform…………………………………………………46

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

MATLAB, which stands for Matrix Laboratory, is a state-of-the-art mathematical software


package, which is used extensively in both academia and industry. It is an interactive program for
numerical computation and data visualization, which along with its programming capabilities provides
a very useful tool for almost all areas of science and engineering. Unlike other mathematical packages,
such as MAPLE or MATHEMATICA, MATLAB cannot perform symbolic manipulations without the
use of additional Toolboxes. It remains however, one of the leading software packages for numerical
computation. As you might guess from its name, MATLAB deals mainly with matrices. A scalar is a
1-by-1 matrix and a row vector of length say 5, is a 1-by-5 matrix.. One of the many advantages of
MATLAB is the natural notation used. It looks a lot like the notation that you encounter in a linear
algebra. This makes the use of the program especially easy and it is what makes MATLAB a natural
choice for numerical computations. The purpose of this experiment is to familiarize MATLAB, by
introducing the basic features and commands of the program. MATLAB is case-sensitive, which means
that a + B is not the same as a + b. The MATLAB prompt (») in command window is where the
commands are entered.
Operators:
1. + addition
2. -subtraction
3. * multiplication
4. ^ power
5. ' transpose
6. \ left division
7. / right division
Remember that the multiplication, power and division operators can be used in conjunction with
a period to specify an element-wise operation.
Built in Functions:
1. Scalar Functions:
Certain MATLAB functions are essentially used on scalars, but operate element-wise when
applied to a matrix (or vector). They are summarized below.
1. sin -trigonometric sine
2. cos -trigonometric cosine
3. tan -trigonometric tangent
4. asin -trigonometric inverse sine (arcsine)

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

Unit Step Function


A unit step function is as defined in equation (2.2)
1, n  0
u[ n ] =  (1.2)
0, n  0
Sinusoidal Signal
A sinusoidal signal is defined in equation (2.3)
x[ n ] = A sin( 2 n +  ), −   n   (1.3)
Exponential Signal
An exponential is defined in equation (2.4)

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');

% unit step function %


% clc;
% clear all;
% close all;
N=100;
t=1:100;
x=ones(1,N);
figure; subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit step function');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit step 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');

% unit ramp function %


% clc;
% clear all;
% close all;
t=0:20;
x=t;
figure; subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit ramp function');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit ramp discrete function');

% 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');

% Aperiodic rectangular pulse %


% clc;
% clear all;
% close all;
t=-10:0.5:10;
pulse = rectpuls(t,2); %pulse of width 2 time units
figure; subplot(2,1,1);
plot(t,pulse,'g');
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 15
xlabel('Time (sec)');
ylabel('Amplitude');
title('continuous rectangular pulse Aperiodic Wave');
subplot(2,1,2);
stem(t,pulse','r');
xlabel('Time (sec)');
ylabel('Amplitude');
title('Discrete rectangular pulse Aperiodic Wave');

% 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

AIM : To perform arithmetic operations: addition, subtraction and multiplication on continuous-time


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.

2. Open new M-file

3. Type the program

4. Save in current directory

5. Compile and Run the program

6. If any error occurs in the program correct the error and run it again

7. For the output see command window\ Figure window

8. Stop the program.

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:

1. Define shift invariance.


2. Define Causal and non-Causal systems.
3. What is the periodicity of x(t) = ej100Πt + 30o?
4. Is the discrete time system describe by the equation y (n) = x(-n) causal or non causal ? Why?
5. Define impulse.

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

3. Type the program

4. Save in current directory

5. Compile and Run the program

6. If any error occurs in the program correct the error and run it again

7. For the output see command window\ Figure window

8. Stop the program.

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');

% Energy and power of a signal

clc; clear all; close all;


%energy of a signal
N=input('enter the value of N');
n=-N:N; x=cos((pi*n)/2);
E=sum(norm(x)^2);
disp('energy is');
disp(E);
%power of a signal p=E/((2*N)+1);
disp('power is'); disp(p);

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.

SOFTWARE REQURIED: MATLAB

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;

% Time period entries


t1 = input('Enter from time: ');
t2 = input('Enter to time: ');

% Number of coefficients is set to 32(-16:1:16.it can be changed it if more are required


% Time period
T = t2 - t1;
% Range of the function variable
k = (t1):0.001:(t2);

% Function
f = (3.*cos(k));

% Fourier Series Coefficients


%Cn

Cn = zeros(1, 31); % Number of fourier series coefficients


C = 0;
j = 1;
for n = -16:1:16 % Number of coefficients
c = zeros(1, length(k));
for u = 1:1:length(k)
c(u) = f(u)* exp( (-1i*2*pi*n*k(u)) / T );
end
C = (1/T) * trapz(k, c); % Using trapizoidal form of integration
Cn(j) = C;
j = j+1;
end

% Using the fourier series coefficients fourier series can be written


% Reconstruction of the function using the fourier series coefficients
S = zeros(1, length(k));
for h = 1:1:length(k)
n = 1;
Su = 0;
for b = -16:1:16 % Number of coefficients
Su = Su + (Cn(n)* exp( (1i*2*pi*b*k(h)) / T ));
n = n+1;
end
Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 27
S(h) = Su;
end

% 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;

% Displaying coefficients, real values, imaginary values, magnitude, phase


disp(Cn);
disp(real(Cn));
disp(imag(Cn));
disp(abs(Cn));
disp(angle(Cn));

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

SOFTWARE REQUIRED: MATLAB

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.

The equation is x(t) = a0 + sum(bk*cos(2*pi*f*k*t)+ck*sin(2*pi*f*k*t))


The sum is obviously from k=1 to k=infinity. a0, bk, and ck are the coefficients

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:

1. Define fundamental frequency.

2. Define Fourier series?

3. What are mutually orthogonal functions?

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.

SOFTWARE REQURIED: MATLAB

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

− jt
F ( ) =  f (t ) e
−
dt

Inverse Fourier Transform of signal F(w) is defined as



1 j t
f (t ) =
2  F ( ) e
−
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”

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:

1. Why do we do Fourier Transform?

2. Where are Fourier transforms used?

3. Find the Fourier transform of u(-t).

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

3. Type the program

4. Save in current directory

5. Compile and Run the program

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

7. For the output see command window\ Figure window

8. Stop the program.

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:

1. Define z-transform and inverse z-transform.

2. Find the Laplace transform of δ(t).

3. What is the main purpose of Laplace transforms?

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.

Software Required: MATLAB

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

% linear convolution of two sequences with and without using function


clc;
clear all;
close all;

x=input('enter the seq1 :: ');


h=input('enter the seq2 :: ');

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:

1. What is the difference between convolution and correlation?


2. What are the applications of convolution?
3. What are the tools used in a graphical method of finding convolution of discrete time signals?

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.

Software Required: MATLAB


Theory:
Cross Correlation Function (CCF) is a measure of similarity between a signal and time
delayed version of the different signal. Given two real-valued sequences 𝑿(𝒏) and 𝒀(𝒏)of
finite energy, cross correlation operation can be represented by a mathematical expression is
as follows
𝑹𝑿,𝒀 (𝒍) = ∑∞
𝒏=−∞ 𝑿(𝒏) 𝒀(𝒏 − 𝒍) (6.1)
Where the index 𝒍is called the shift or lag parameter.
Auto correlation function (ACF) is a measure of similarity between a signal and time
delayed version of the same signal. Given real-valued sequence 𝑿(𝒏) of finite energy, auto
correlation operation can be represented by a mathematical expression is as follows
𝑹𝑿,𝒀 (𝒍) = ∑∞
𝒏=−∞ 𝑿(𝒏) 𝑿(𝒏 − 𝒍) (6.2)

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

% cross correlation between two sequences

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');

% cross correlation between two sequences


y=xcorr(x,h);
subplot(2,2,3);
stem(y);
xlabel('n');
ylabel('y(n)');
title(' cross correlation between two sequences ');

% auto correlation of input sequence


z=xcorr(x,x);
subplot(2,2,4);
stem(z);
xlabel('n');
ylabel('z(n)');
title('auto correlation of input sequence');

% cross correlation between two signals

% generating two input signals


t=0:0.2:10;
x1=3*exp(-2*t);
h1=exp(t);
figure;
subplot(2,2,1);
plot(t,x1);
xlabel('t');
ylabel('x1(t)');

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

Aim: To write a MATLAB program to verify Sampling Theorem.

Software Required: MATLAB

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;

Fs = input('Enter Sampling Frequency in Hz ....:: ');


Fm = input('Enter Message Frequency in Hz .....:: ');

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:

1.state sampling theorm

2. Define Nyquist rate and Nyquist interval.

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.

Software Required: MATLAB

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:

1. Define z-transform and inverse z-transform.

2. List the properties of region of convergence for the z-transform.

3. List the properties of z-transform

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:-

1..What are the advantages of digital filter over analog filters?

2.What is Gaussian noise characteristics?

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.

Software Required: MATLAB


Theory:
y = lowpass(x,wpass) filters the input signal x using a lowpass filter with normalized
passband frequency wpass in units of π rad/sample. lowpass uses a minimum-order filter with
a stopband attenuation of 60 dB and compensates for the delay introduced by the filter. If x is a
matrix, the function filters each column independently.
y = lowpass(x,fpass,fs) specifies that x has been sampled at a rate of fs hertz. fpass is the
passband frequency of the filter in hertz.
y = lowpass(xt,fpass) lowpass-filters the data in timetable xt using a filter with a passband
frequency of fpass hertz.
The function independently filters all variables in the timetable and all columns inside each
variable. y = lowpass(___,Name,Value) specifies additional options for any of the previous
syntaxes using name-value pair arguments.

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:

1. Which is the example of audio signal?

2. What is low pass and bandpass signal?

3. What is the human being audible frequency?

Sigtnals and SystemsLab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page 51

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy