20ecl33 SS Lab Manual
20ecl33 SS Lab Manual
DEPARTMENT OF ECE
Prepared by
Ms. N.NAGA SWATHI, Asst. Prof.
II B.Tech.–III Semester
SIGNALS AND SYSTEMS LAB (20ECL33)
Lectures 0 Tutorial 0 Practical 3 Credits 1.5
Continuous Internal Assessment : 30 Semester End Examination : 70
(3 Hours)
LIST OF PROGRAMS
S. No. Name of the Program
1. Basic Operations on Matrices.
3. Generation of basic continuous time signals namely unit impulse, step, ramp, exponential and
Sinusoidal signals.
4. Generation of basic discrete time signals namely unit impulse step, ramp, exponential and
Sinusoidal signals.
Aim: To perform basic operations on matrices such as addition, multiplication, transpose, length
of the matrix, size of the matrix, mean of the matrix, inverse of the matrix etc.
Theory:
transpose(a) transpose (a) is called for the syntax a.' when a is an object.
a.' computes the non-conjugate transpose of matrix a
* X*Y is the matrix product of X and Y. Any scalar (a 1-by-1 matrix) may
Matrix multiply multiply anything. Otherwise, the number of columns of X must equal the
number of rows of Y.
Array multiply. X and Y must have the same dimensions unless one is a scalar. A scalar can
be multiplied into anything.
Size D = size(X), for M-by-N matrix X, returns the two-element row vector.
For matrices, mean(X) is a row vector containing the mean value of each
column.
1
SIGNALS & SYSTEMS LAB 20 ECL33
Matlab Program:
A=[1 2 3; 1 0 1; 2 1 4];
B=[1 1 3; 0 5 7; 2 7 4];
L=plus(A,B)
M=mtimes(A,B)
N=times(A,B)
O=A.’
P=max(size(B))
2
SIGNALS & SYSTEMS LAB 20 ECL33
OUTPUTS:
C=
2 3 6
1 5 8
4 8 8
D=
7 32 29
3 8 7
10 35 29
E=
1 2 9
0 0 7
4 7 16
F=
1 1 2
2 0 1
3 1 4
G=
3
H=
3
I= 3
J=
1.3333 1.0000 2.6667
colvec = 13
20
5
rowvec =
1 2 3
sub_matrix = 0 1
1 4
3
SIGNALS & SYSTEMS LAB 20 ECL33
col_vector = 2
0
1
row_vector = 2 1 4
K=
0.5000 2.5000 -1.0000
1.0000 1.0000 -1.0000
-0.5000 -1.5000 1.0000
L=
2 3 6
1 5 8
4 8 8
M=
7 32 29
3 8 7
10 35 29
N=
1 2 9
0 0 7
4 7 16
O=
1 1 2
2 0 1
3 1 4
P=
3
4
SIGNALS & SYSTEMS LAB 20 ECL33
Theory:
1 Line Plots: The plot function creates simple line plots of x and y values.
2 Stem Plots: The stem function draws a marker for each x and y value
with a vertical line connected to a common baseline.
3 Scatter Plots: The scatter function draws a scatter plot of x and y values.
4 Bar Plots: The bar function creates vertical bar charts. The barh function
creates horizontal bar charts.
5 Stairstep Plots: The stairs function creates a stairstep plot. It can create a
stairstep plot of Y values only or a stairstep plot of x and y values.
6 Errorbar Plots: The errorbar function draws a line plot of x and y values
and superimposes a vertical error bar on each observation. To specify the
size of the error bar, pass an additional input argument to
the errorbar function
7 Polar Plots: The polarplot function draws a polar plot of the angle values
in theta (in radians) versus the radius values in rho.
5
SIGNALS & SYSTEMS LAB 20 ECL33
Program:
2 y1 = sin(x.^2);
y2 = cos(x.^2);
plot(x,y1,x,y2)
3 x = -2.9:0.2:2.9;
y = exp(-x.*x);
bar(x,y)
4 x = 0:0.25:10;
y = sin(x);
stairs(x,y)
6
SIGNALS & SYSTEMS LAB 20 ECL33
5 x = -2:0.1:2;
y = erf(x);
eb = rand(size(x))/7;
errorbar(x,y,eb)
7. x = 0:0.1:4;
y = sin(x.^2).*exp(-x);
stem(x,y)
7
SIGNALS & SYSTEMS LAB 20 ECL33
Program 3: Generation of basic continuous time signals namely unit impulse, step,
ramp, exponential and Sinusoidal signals.
Aim: To generate basic continuous time signals namely unit impulse, step, ramp, exponential
and Sinusoidal signals.
Theory:
A continuous-time signal is a signal that can be defined at every instant of time. A continuous-
time signal contains values for all real numbers along the X-axis.
Unit Impulse An ideal impulse function is a function that is zero everywhere but at the origin,
where it is infinitely high. However, the area of the impulse is finite.
Unit Step
The unit step function, also known as the Heaviside function, is defined as
Ramp
The ramp function is a unary real function, easily computable as the mean of the
independent variable and its absolute value.
8
SIGNALS & SYSTEMS LAB 20 ECL33
Exponential Exponential signal is of two types. These two types of signals are real
signal exponential signal and complex exponential signal which are given below.
Where both "A" and "σ" are real. Depending on the value of "σ" the signals will
be different. If "σ" is positive the signal x(t) is a growing exponential and if
"σ" is negative then the signal x(t) is a decaying exponential. For σ=0, signal
x(t) will be constant.
where:
10
SIGNALS & SYSTEMS LAB 20 ECL33
MATLAB PROGRAM:
%(iv)exponential signal
L=input('Length of exponential signal, L=');
B=input('Amplitude of exponential signal, B=');
a=input('Value of a=');
t=0:0.01:L;
x=B*exp(a*t);
subplot(5,1,4);
plot(t,x);
xlabel('Time');
ylabel('Amplitude');
title('Exponential signal');
11
SIGNALS & SYSTEMS LAB 20 ECL33
%(v)sinusoidal signal
L=input('Length of sinusoidal signal, L=');
T=input('Time period of sinusoidal signal, T=');
A=input('Amplitude of sinusoidal signal, A=');
phi=input('Initial phase of sinusoidal signal, phi(in radian)=');
t=0:0.01:L;
x=A*cos((2*pi*t/T)+phi);
subplot(5,1,5);
plot(t,x);
xlabel('Time');
ylabel('Amplitude');
title('sinusoidal signal');
12
SIGNALS & SYSTEMS LAB 20 ECL33
OUTPUT :
13
SIGNALS & SYSTEMS LAB 20 ECL33
Program 4: Generation of basic discrete time signals namely unit impulse, step, ramp,
exponential and Sinusoidal signals.
Aim: To generate basic discrete time signals namely unit impulse, step, ramp, exponential
and Sinusoidal signals.
Theory:
Signals that are discrete in time but continuous in amplitude are referred to as discrete-time
signals.
Unit Impulse An ideal impulse function is a function that is zero everywhere but at the origin,
where it is infinitely high. However, the area of the impulse is finite.
Unit Step
The unit step function, also known as the Heaviside function, is defined as
Ramp The ramp function is a unary real function, easily computable as the mean of the
independent variable and its absolute value.
14
SIGNALS & SYSTEMS LAB 20 ECL33
where:
• A = the amplitude, the peak deviation of the function from zero.
• f = the ordinary frequency, the number of oscillations (cycles) that occur
each second of time.
• ω = 2πf, the angular frequency, the rate of change of the function
argument in units of radians per second
• Ф = the phase, specifies (in radians) where in its cycle the oscillation
is at t = 0.
15
SIGNALS & SYSTEMS LAB 20 ECL33
MATLAB PROGRAM:
%(iv)exponential sequence
L=input('Length of exponential sequence, L=');
n=0:L-1;
B=input('Amplitude of exponential sequence, B=');
a=input('Value of a=');
e=exp(a*n);
x=B*e;
subplot(5,1,4);
stem(n,x);
xlabel('Time index');
ylabel('Amplitude');
16
SIGNALS & SYSTEMS LAB 20 ECL33
%(v)sinusoidal sequence
L=input('Length of sinusoidal sequence, L=');
N=input('Time period of sinusoidal sequence , N=');
A=input('Amplitude of sinusoidal sequence , A=');
phi=input('Initial phase of sinusoidal sequence, phi(in radian)=');
n=0:L-1;
x=A*cos((2*pi*n/N)+phi);
subplot(5,1,5);
stem(n,x);
xlabel('Time');
ylabel('Amplitude');
title('sinusoidal sequence');
OUTPUT:
17
SIGNALS & SYSTEMS LAB 20 ECL33
Aim: Matlab programs to explain the Operations on Signals and Sequences such
as Addition, Multiplication.
Theory:
1. Addition: Addition can be carried out using the ‘ + ‘ symbol and plotting will give you
the result.
MATLAB PROGRAM:
clc;
clear all;
close all;
t=0:.01:1;
18
SIGNALS & SYSTEMS LAB 20 ECL33
% 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');
OUTPUT :
19
SIGNALS & SYSTEMS LAB 20 ECL33
Aim: Matlab program to find the Even and Odd Parts of Signal.
Theory:
Any signal x(t) can be written as the sum of an even signal and odd signal.
x(t)=xe(t)+xo(t) (4)
where, xe(t) is the even part and xo(t) is the odd part.
MATLAB PROGRAM:
clc;
close all;
clear all;
20
SIGNALS & SYSTEMS LAB 20 ECL33
ylabel('amplitude')
title('even part of the signal')
p=x-y
subplot(2,2,4)
plot(t,p/2)
xlabel('t');
ylabel('amplitude');
title('odd part of the signal');
OUTPUT:
21
SIGNALS & SYSTEMS LAB 20 ECL33
Aim: Matlab program to verify linearity property of a given Continuous /discrete system.
Theory:
If a system is linear, this means that when an input to a given system is scaled by a
value, the output of the system is scaled by the same amount. A linear system also
obeys the principle of superposition. This means that if two inputs are added together
and passed through a linear system, the output will be the sum of the individual inputs'
outputs.
A time-invariant system has the property that a certain input will always give the
same output (up to timing), without regard to when the input was applied to the
system.
MATLAB PROGRAM:
% Verification of Linearity
clc;
clear all;
close all;
22
SIGNALS & SYSTEMS LAB 20 ECL33
% response of x and x1
yo1 = conv(x,h);
y1 = conv(x1,h);
% scaled response of x1
y1s = a1 * y1;
% response of x2
y2 = conv(x2,h);
% scaled response of x2
y2s = a2 * y2;
yo2 = y1s + y2s;
disp ('Input signal x1 is ');
disp(x1);
disp ('Input signal x2 is ');
disp(x2);
disp ('Output Sequence yo1 is ');
disp(yo1);
disp ('Output Sequence yo2 is ');
disp(yo2);
if ( yo1 == yo2 )
disp(' yo1 = yo2. Hence the LTI system is LINEAR ')
end;
OUTPUT:
For Linearity the output will be displayed as Linear or Non Linear System.
23
SIGNALS & SYSTEMS LAB 20 ECL33
Theory:
Convolution is a mathematical operation on two functions (f and g) that produces a
third function expressing how the shape of one is modified by the other. The term convolution
refers to both the result function and to the process of computing it. It is defined as the integral
of the product of the two functions after one is reversed and shifted.
MATLAB PROGRAM:
clc;
close all;
clear all;
%program for convolution of two sequences
x=input('enter input sequence');
h=input('enter impulse response');
y=conv(x,h);
subplot(3,1,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input signal')
subplot(3,1,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('impulse response')
subplot(3,1,3);
stem(y);
xlabel('n');
ylabel('y(n)');
title('linear convolution')
disp('The resultant signal is');
disp(y)
24
SIGNALS & SYSTEMS LAB 20 ECL33
y1=conv(x1,h1);
figure;
subplot(3,1,1);
plot(t,x1);
xlabel('t');
ylabel('x(t)');
title('input signal')
subplot(3,1,2);
plot(t,h1);
xlabel('t');
ylabel('h(t)');
title('impulse response')
subplot(3,1,3);
plot(y1);
xlabel('n');
ylabel('y(n)');
title('linear convolution');
OUTPUT:
25
SIGNALS & SYSTEMS LAB 20 ECL33
26
SIGNALS & SYSTEMS LAB 20 ECL33
Aim: Matlab programs to perform Autocorrelation and Cross correlation between Signals and
Sequences.
Theory:
Autocorrelation, also known as serial correlation, is the correlation of a signal with a delayed copy
of itself as a function of delay. Informally, it is the similarity between observations as a function of
the time lag between them. The analysis of autocorrelation is a mathematical tool for finding
repeating patterns, such as the presence of a periodic signal obscured by noise, or identifying the
missing fundamental frequency in a signal implied by its harmonic frequencies. It is often used in
signal processing for analyzing functions or series of values, such as time domain signals.
MATLAB PROGRAM:
clc;
close all;
clear all;
% two input sequences
x=input('enter input sequence');
h=input('enter the impulse suquence');
subplot(2,2,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input sequence');
subplot(2,2,2);
stem(h);
xlabel('n');
27
SIGNALS & SYSTEMS LAB 20 ECL33
ylabel('h(n)');
title('impulse signal');
% cross correlation
subplot(2,2,3);
z1=xcorr(x1,h1);
plot(z1);
xlabel('t');
ylabel('z1(t)');
title('cross correlation ');
28
SIGNALS & SYSTEMS LAB 20 ECL33
% auto correlation
subplot(2,2,4);
z2=xcorr(x1,x1);
plot(z2);
xlabel('t');
ylabel('z2(t)');
title('auto correlation ');
OUTPUT :
29
SIGNALS & SYSTEMS LAB 20 ECL33
30
SIGNALS & SYSTEMS LAB 20 ECL33
18ECL43 : SIGNALS AND SYSTEMS LAB MANUAL
Theory:
A continuous time signal can be represented in its samples and can be recovered back
when sampling frequency fs is greater than or equal to the twice the highest frequency
component of message signal. i. e.
fs≥2fm.
Proof: Consider a continuous time signal x(t). The spectrum of x(t) is a band limited to
fm Hz i.e. the spectrum of x(t) is zero for |ω|>ωm.
Sampling of input signal x(t) can be obtained by multiplying x(t) with an impulse train
δ(t) of period Ts. The output of multiplier is a discrete signal called sampled signal
which is represented with y(t) in the following diagrams:
Here, you can observe that the sampled signal takes the period of impulse.
41
SIGNALS & SYSTEMS LAB 20 ECL33
MATLAB PROGRAM:
clc;
clear all;
close all;
t=-10:.01:10;
T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('time');
ylabel('x(t)');
title('continous time signal');
grid;
n1=-4:1:4;
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs<2fm');
hold on;
subplot(2,2,2);
plot(n1,x1);
grid;
n2=-5:1:5;
x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
stem(n2,x2);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs=2fm');
hold on;
subplot(2,2,3);
plot(n2,x2)
grid;
n3=-20:1:20;
x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4);
42
SIGNALS & SYSTEMS LAB 20 ECL33
18ECL43 : SIGNALS AND SYSTEMS LAB MANUAL
stem(n3,x3);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs>2fm')
hold on;
subplot(2,2,4);
plot(n3,x3)
grid;
OUTPUT:
43