You are on page 1of 34

BHUBANESWAR COLLEGE

OF ENGINEERING

Signals & Systems


Lab Manual
Department of Electronics Communication Engineering
EXPAREMENT 1

AIM OF THE EXPERIMENT


Write a program to Generate various signals and sequences (Periodic and a periodic), such as Unit Impulse,
Unit Step, Square, Triangular, Sinusoidal, Ramp, Sinc.

SOFTWARE REQUIRED: PC loaded with MATLAB software

THEORY:
If the amplitude of the signal is defined at every instant of time then it is called continuous time signal. If the
amplitude of the signal is defined at only at some instants of time then it is called discrete time signal. If the
signal repeats itself at regular intervals then it is called periodic signal. Otherwise they are called aperiodic
signals.

EX: ramp, Impulse,unit step, sinc- Aperiodic signals Square, sawtooth,


triangular sinusoidal – periodic signals.

Ramp signal: The ramp function is a unitary real function, easily computable as the mean of the independent
variable and its absolute value.This function is applied in engineering. The name ramp function is derived from
the appearance of its graph.

r(t) = t when t≥0


=0 else
Unit impulse signal: One of the more useful functions in the study of linear systems is the "unit impulse
function."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

Y(t)= 1 when t=0


=0 other wise

Unit step signal: The unit step function and the impulse function are considered to be fundamental functions in
engineering, and it is strongly recommended that the reader becomes very familiar with both of these functions.

=0 if t < 0
u(t) = 1 if t > 0
=1/2 If t=0
Sinc signal: There is a particular form that appears so frequently in communications engineering, that we
give it its own name. This function is called the "Sinc function”.

PROCEDURE:

1. Click on MATLAB Icon

2. Type the program on editor window

3. Save the program

4. Execute the program and observe the output/wave forms

PROGRAM:

//continuous ramp signal


t = 0 : 0.001 : 1; y = 0.5
* t; plot( t , y );
5. xlabel (' ---------- >Time Index t (sec.)'); ylabel (' ---------- >Amplitude');
6. title ('Ramp Signal Sequence');
7.
8. //discrete ramp signal
9. n = 0 : 0.1 : 1; y = 0.5 * n; plot2d3(n,y); xlabel (' ----------- >Time Index n');
10.
11. ylabel ('---------->Amplitude');
12. title ('Ramp Signal Sequence');
13.
14.
15. //continuous sinc signal t=linspace(-10 , 10); y=sinc(t); plot(t,y); xlabel("Time Index t (sec.)");
ylabel("Amplitude"); title("Sinc Signal Sequence");
16.
17.
18. //discrete sinc signal n =linspace(-10 , 10); y =sinc(n); plot2d3(n,y); xlabel("Time Index n");
ylabel("Amplitude"); title("Sinc Signal Sequence");
19.
20. // continuous Sinusoidal Signal a=input('Enter amplitude'); t=0:0.001:1;
21. p=a*sin(2*%pi*10*t);
22. plot(t,p); title("Sinusoidal sequence"); xlabel("time"); ylabel("amplitude");
23.
24. // discrete sinuoidal signal a=input('Enter magnitude'); n
= 0:100; x =a*sin(((2*0.05)*%pi)*n); plot2d3(n,x); title("Sinusoidal sequence"); xlabel("samples");
ylabel("magnitude");

// continuous square wave Signal:


a=input('Enter amplitude'); t=0:0.001:1;
d=a*squarewave(2*%pi*10*t);
plot(t,d);
xlabel(" ----------- >Time Index t (sec.)"); ylabel(" ----------- >Amplitude"); title("Square Wave Signal
Sequence");
// discrete square wave signal a=input('Enter amplitude'); n=0 : 0.01 :1;
d=a*squarewave(2*%pi*10*n); plot2d3(n,d); xlabel("---------->Time Index n"); ylabel("----------
>Amplitude"); title("Square Wave Signal Sequence");

// Triangular Wave Signal

Fs = 20; // samples per second t_total= 100; // seconds n_samples= Fs * t_total; t = linspace(0, t_total,
n_samples); f=40; // sound frequency
tri_wave=(2/%pi)*asin(sin(2*%pi*f*t)); plot(t,tri_wave);
xlabel(' ----------- >Time Index t (sec.)'); ylabel(' ------------ >Amplitude');
title ('Triangular Wave Signal Sequence');

// traiangular wave sequence Fs = 20; // samples per second t_total= 10; // seconds n_samples= Fs * t_total;
t = linspace(0, t_total, n_samples); f=40; // sound frequency
tri_wave=(2/%pi)*asin(sin(2*%pi*f*t)); plot(t,tri_wave); xlabel(' ----------- >Time Index t (sec.)'); ylabel('
------------ >Amplitude');
title ('Triangular Wave Signal Sequence');

// Sawtooth Wave Signal Fs = 20; // samples per second t_total= 10; // seconds n_samples= Fs * t_total; t =
linspace(0, t_total, n_samples); f=500; // sound frequency// Sawtooth wave
saw_wave=2*(f*tfloor(0.5+f*t)); plot(t,saw_wave); xlabel(" ----------- >Time Index t (sec.)"); ylabel("
------------ >Amplitude"); title ("Sawtooth Wave Signal Sequence");
// sawtooth wave sequenceFs = 20; // samples per second

t_total= 10; // secondsn_samples= Fs *


t_total; n = linspace(0, t_total, n_samples); f=500; // sound frequency// Sawtooth wave
saw_wave=2*(f*nfloor(0.5+f*n)); plot2d3(n,saw_wave); xlabel("---------->Time Index ");
ylabel("----------->Amplitude");
title ("Saw tooth Wave Signal Sequence");

// Unit Impulse Signal and Sequence: t=-


5:1:5;
a=[zeros(1,5) 1 zeros(1,5)]; k=input("enter the
amplitude");
b=k*a; subplot(2,1,1);
plot(t,b);
xlabel("impulse response", "amplitude", "time");
subplot(2,1,2); plot2d3(t,b);
xlabel("impulse response", "amplitude", "time");

// Unit Step Signal and Sequence: // Discrete Signal t=0:4; y=ones(1,5); subplot(2,1,1); plot2d3 (t,y);
xlabel('time'); ylabel('amplitude');

title('Unit Step Discrete Signal'); // Continuous


Signal subplot(2,1,2); plot(t,y); xlabel('time');
ylabel('amplitude'); title('Unit Step Continuous Signal');
OUTPUT:
enter the amplitude 9

CONCLUSION: -

Hence various signals & sequences are generated using MATLAB software
EXPAREMENT 2

AIM OF THE EXPERIMENT:


To find the fourier transform of a given signal and plotting itsmagnitude and
phase spectrum

EQUIPMENTS:
PC with window
MATLAB Software

Fourier Transform Theorems:


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/Tin the Fourier series of ƒ is given by By
definition Fourier Transform of signal f(t) is defined as

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


PROGRAM:

t = 0:1/50:10-1/50;
x = sin(2*pi*15*t) + sin(2*pi*20*t);
plot(t,x)
y = fft(x);
f = (0:length(y)-1)*50/length(y);
plot(f,abs(y))
title('Magnitude')
n = length(x);
fshift = (-n/2:n/2-1)*(50/n);
yshift = fftshift(y);
plot(fshift,abs(yshift))
ynoise = fft(xnoise);
ynoiseshift = fftshift(ynoise);
power = abs(ynoiseshift).^2/n;
plot(fshift,power)
title('Phase')

CONCLUSION: -
EXPERIMENT 3

AIM OF THE EXPERIMENT :

Write a program to find response of a low pass filter and high pass filter

Purpose
The purpose of this lab is to introduce you to Low Pass and High Pass Filters. As part of performing
this lab you will
• Determine the amplitude and frequency response characteristics of Low and
High
Pass filters,
• Compare passive and active LPF and HPF filter configurations, and
•Compare theoretical models with actual filters.

THEORY
In this experiment you will design, build 1, and test four filters. The configurations you will build are
• Passive Low-Pass Filter,
• Active Low-Pass Filter, •Passive High-Pass Filter,
and •Active High-Pass Filter. For each of the
configurations you will
1. Design the filter for a specified cut-off frequency,
2. Model the filter in MatLab,
3. Simulate the design with PSpice2, and
4. Test the design in the Lab.
Steps 1, 2, and 3 are Prelab activities. Step 4 will be performed during the lab period.
In your report you will compare the theoretical and actual amplitude and phase plots for each of the
four configurations.
If you are rusty on transfer functions or op amp usage you may want to review those subjects.
1. Draw graphs showing the frequency responses of an ideal low-pass filter (LPF) and an
ideal high-pass (HPF) filter.
2. Generate a signal in MatLab composed of two sine waves using the following
parameters:
a) f1= 2000 Hz
b) f2= 40000 Hz
c) 0 t  2 milliseconds
d) Ts = 5 microseconds
e) y(t) = sin ( 2 f1 t ) + 0.25 cos ( 2 f2 t )
3. Plot the time domain and the frequency domain representations of the signal.
4. "Filter" the wave form by "zeroing out" the high frequency components of the FFT
wave form:
There are two ways in MatLab to "filter" a wave form. One technique is to "zero out" the higher
frequency elements of the FFT. The other is to use the transfer function of a low pass
filter. In the steps below you will zero out the high frequency elements of the FFT. a)%
create a new vector containing only the low
b) % frequency components of Y
c) L = length(Y);
d) NewY = zeros(L,1);
e) % define the number of data points to copy from the original file
f) NewY(1:b)=Y(1:b);
As an option, instead of replacing the values of higher frequency region with zeros, it is also feasible
to replace the original values with very small values, such as 0.001, which represent out of
band noise.
Although at this point you are not actually filtering the signal, you are performing the same kind of
function that a Low Pass Filter performs. The performance of this filtering method depends
on the number of vector elements you replace with zeros in the high frequency components
of the FFT.
5. After filtering in the frequency domain, reconstruct the signal using "ifft".
In your report, compare the reconstructed signal with the original signal in the time domain.
6. Repeat this procedure for the lower frequency region of the FFT and observe the output.
This method introduces the concept of filtering. This filtering is considered ideal filtering in terms
of the performance of the filtering. However this filtering requires additional procedure for
reconstruction of the signal. In the ‘real world’ the goal is to design filters that perform as
well as this simulation.

7. Use Convolution to demonstrate filtering. (This will use the convolution technique you
used in Lab 2.)
a) Determine the impulse response of the filter.
b) Convolve the impulse response of the filter with the signal that you are going to
filter.
Pre3_13.m simulates LPF filtering using this filtering method in MatLab. In your Lab Report,
comment on the performance of the filter.

1. Build the following passive high-pass filter in MicroSim and determine its transfer function
and cut-off frequency:
Figure 2. RC High Pass Filter
2. Build the following active low-pass filter in MicroSim and determine its transfer function
and cut-off frequency:

Figure 3. Sallen-Key Equal Component Active Low Pass Filter

3. Build the following active high-pass filter in MicroSim and determine its transfer function
and cut-off frequency:
Figure 4. Sallen-Key Equal Component Active High Pass Filter
Lab Period – Low Pass and High Pass Filters

Parts required for this lab:


Resistors:
Determined by circuit
Capacitors:
Determined by circuit
Integrated circuits:
2 – Op-amp uA741

Frequency response of a RC low pass filter


In this section you will determine the frequency response of an RC Low Pass Filter. Also, you will
verify the filtering process by applying the sum of two sinusoids at the input and measuring the
attenuation caused by the filter on the amplitudes of the two signals.
Hint: If you decide to print the graphs from LabVIEW during the lab period, you may want to zoom
the display to improve the resolution of the plots before you print them.
1. Build the circuit shown in Figure 1. Manually determine its cut-off frequency. Recall that
voltage at the cut-off frequency is 0.707 (- 3 dB) times the input voltage to the filter.
Connect channel 2 of the oscilloscope to the input and channel 1 to the output.
2. Use RESPONSE.VI to obtain the frequency response of this filter. Enter the parameters
for the sweep. Use Lowfreq = 100 Hz, Upperfreq = 100000 Hz, Amplitude = 10 V,
points/decade = 10. Note the GPIB address of the signal generator that you are using.
Select an appropriate filename to save the data in the "Data file" box. Remember to use a
different filename each time that you run the VI.
3. Notice that the frequency axis in the graph has a logarithmic scale. Report the cut-off
frequency by finding the -3 dB point (i.e. the point which is 3 dB below the maximum
amplitude). Also, find the amplitudes at f1 = 10 kHz and f2 = 100 kHz.
Cut-off frequency (fc) =
Amplitude at f1(m1) =
Amplitude at f2(m2) =
4. From the last two coordinates, estimate the slope of the magnitude response. Determine
the phase shift at the cut-off frequency. Derive a function to determine the phase shift of
this circuit and calculate the phase shift at the theoretical cut-off frequency. Compare it
with the measured value.
Slope (dB/decade) =
Phase shift at cut-off frequency = Theoretical = Measured
=
Hint: To make the measurements easier, zoom in on the graph by changing the lower and upper
values shown for each axis. Select by clicking on the parameter to be changed and enter the
new value.
1.Disconnect the signal generator from the circuit. Connect the ground clips of the two signal
generators to the circuit ground, and the red test leads to the circuit's input. Set both signal
generators to produce 10 VPP sine waves. Set one of the function generators to produce a 10
kHz sine wave, and the other function generator to 100 kHz. Connect channel 1 of the
oscilloscope to the same point as the red clips. Connect oscilloscope channel 2 to ground.

Red Test Lead

Red Test Lead

Function
Generator 1

Function Black Test Lead


Generator 2
Black Test Lead
Figure 5. Function Generator Connection for LPF and HPF Filters

2. Using WAVEFFT.VI, obtain the frequency spectrum of the input signal. Enter ts= 8E-3 as
the time span in the control panel of the VI. Measure the amplitude of the main peaks of the
spectrum.
Amplitude at f1(pi1) =
Amplitude at f2(pi2) =
3. Apply the signal to the circuit by connecting the leads as shown in Figure 5. Move the
channel 1 probe to the output of the RC Low Pass Filter. Run WAVEFFT.VI using the
same time span, remember to save the data with a different filename. Measure the amplitude
of the main peaks in the displayed spectrum.
Amplitude at f1(po1) =
Amplitude at f2(po2) =
4. What is the relationship between m1, pi1and po1? Verify your conclusion with m2, pi2 and
po2.

Frequency response of an RC High Pass Filter


1. Construct an RC High Pass Filter as shown in Figure 2.
2. Repeat the procedure described in LAB 3.1 to analyze the frequency response of the RC
High Pass Filter. Use f1=100 Hz, f2=1000 Hz, and ts= 0.5 (i.e. 500E-3).

PROGRAMS:-

%Design of FIR lowpass fillter


clc
clear all
w1=boxcar(23+1)
wn=0.5
b=fir1(23,wn,w1)
a=1
[H,w]=freqz(b,a)
mag=abs(H)
db=20*log((mag+eps)/max(mag))
pha=angle(H)
grd=grpdelay(b,a,w)
%For plotting
subplot(2,2,1)
plot(w/(2*pi),mag);grid
xlabel('frequency in pi units')
title('magnitude responce')
subplot(2,2,2)
plot(w/(2*pi),db);grid
xlabel('frequency in pi units')
ylabel('db')
title('log magnitude responce')
subplot(2,2,3)
plot(w/(2*pi),pha);grid
xlabel('frequency in pi units')
ylabel('phase in pi units')
title('phase response')
subplot(2,2,4)
plot(w/(2*pi),grd);grid
xlabel('frequency in pi units')
ylabel('delay in samples')
Frequency response of an active low-pass active

1. Construct the active Low Pass Filter shown in Figure 3 using the following
parameters:. Equipment Settings:
VCC 18 V (power supply voltages)
VSS -18 V
f13,000 Hz
f230,000 Hz
Amplitude 5 Vpp
LabVIEW Settings:
Lowfreq 100 Hz Upperfreq 30 kHz
points/decade 10
ts20E-3
2. Analyze the response of the filter by following the steps of Lab 3.1.
EXPERIMENT 4
AIM: Write a program to perform the operations on signals and sequences such as addition, multiplication,
scaling, shifting, folding and also compute energy and power.

SOFTWARE REQUIRED: PC loaded with MATLAB software.

THEORY:
Signal Addition

Addition: any two signals can be added to form a third signal,


z (t) = x (t) + y (t)

Multiplication:
Multiplication of two signals can be obtained by multiplying their values at every instants . z
z(t) = x (t) y (t)

Time reversal/Folding:
Time reversal of a signal x(t) can be obtained by folding the signal about t=0.
Y(t)=y(-t)
Signal Amplification/Scaling : Y(n)=ax(n) if a < 1 attnuation
a >1 amplification
Time shifting: The time shifting of x(n) obtained by delay or advance the signal in time by
using y(n)=x(n+k)
If k is a positive number, y(n) shifted to the right i e the shifting delays the signal

If k is a negative number, y(n ) it gets shifted left. Signal Shifting advances the signal

Energy:

Average power:

PROCEDURE:
1.Click on MATLAB Icon

2. Type the program on editor window

3.Save the program

4.Execute the program and observe the output/wave forms

PROGRAM:

// Addition
x=input('Enter the sequence 1=');
y=input('Enter the sequence 2=');
m=length(x); n=length(y); if m>n
y=[y,zeros(1,m-n)];
else

x=[x,zeros(1,n-m)];

end z=x+y;
disp(z,'Addition result of two unequal length sequences:=');

// Multiplication
x=input('Enter the sequence 1=');
y=input('Enter the sequence 2=');
m=length(x); n=length(y); if m>n
y=[y,zeros(1,m-n)]; else
x=[x,zeros(1,n-m)];
end z = x.*y;
disp(z, ' Multiplication result of two unequal lengths equences:= ' );

// Folding Operation
x = input( ' Enter the input sequence e := ' ); m = length (x);
s = input( ' Enter the starting point of original signal=' ); h
= s + m -1; n = s :1: h; subplot(2 ,1
,1)x_location= " o r i g i n "; y_location= "
o r i g i n "; data_bounds= [ -5 ,0;5 ,5];
plot2d3 (n,x)xlabel( ' n===>' ) ylabel( '
Amplitude' )title( ' Original Sequence ' )
subplot(2 ,1 ,2)x_location= " o r i g i n ";
y_location= " o r i g i n "; data_bounds= [
-5 ,0;5 ,5]; plot2d3 (-n,x)xlabel( ' n===>' )
ylabel( ' Amplitude' )title( ' Folded
Sequence ' )
// Scaling Operation
x = input( ' Ent e r input Sequence := ' );
m = length(x);
s= input( ' Enter starting point of originalsignal:= ' ) h
= s+m-1;
n = s :1: h;
C = input( 'Ent e r Compression factor Time Scaling factor' )

n = s/C:1/C:h/C ; subplot(2 ,2 ,3)x_location=


" o r i g i n "; y_location= " o r i g i n ";
data_bounds= [ -10 ,0;10 ,10]; plot2d3
(n,x)xlabel( ' n===>' ) ylabel( ' Amplitude' )
title( ' Time Scaling - Compressed Sequence ' )

// shifting operation

x = input( ' Enter the input sequence := ' ) m = length (x);


lx = input( ' Enter the starting point of original signal := ' ) hx= lx+m-1; n
= lx :1: hx;

subplot(3 ,1 ,1) x_location


= " o r i g i n "; y_location
= " o r i g i n "; data_bounds= [ -10 ,0;10 ,10];
plot2d3 (n,x); xlabel( ' n===>' ) ylabel( '
Amplitdue' )title( ' Original Sequence' ) d =
input( ' Enter the delay := ' ) n = lx+d:1: hx+d;
subplot(3 ,1 ,2) x_location
= " o r i g i n "; y_location
= " o r i g i n "; data_bounds= [ -10 ,0;10 ,10];
plot2d3 (n,x)xlabel( ' n===>' ) ylabel( '
Amplitude' )title( ' Delayed Sequence ' )

// Energy and Average power


p = input('Enter the sequence ...:: ');
M = length(p); disp(M) sum
= 0;
for i= 1:M, sum=sum +(i*i);
end;
disp('Energy of the given sequence is .......... :: ');
Energy =sum

disp(Energy);

disp('Average Power of the given sequence is ........... :: ');


Average_power= sum/M disp(Average_power)

// Addition, multiplication, shifting, folding, and scaling of signals: n1=0:7;


y1=[zeros(1,3),ones(1,5)];
y2=n1-2; y3=n1/4;
y4=n1; y5=y1+y2;
y6=y3.*y4;

subplot(3,2,1); plot2d3 (n1,y1);


xlabel('time');

ylabel('amplitude'); title('Sample Signal');

subplot(3,2,2); plot2d3 (n1,y2); xlabel('time');


ylabel('amplitude'); title('Advancing Shifting
Signal');

subplot(3,2,3); plot2d3(n1,y3);
xlabel('time'); ylabel('amplitude');
title('scaling of Signals');

subplot(3,2,4); plot2d3(n1,y4);
xlabel('time'); ylabel('amplitude');
title('Folded Signal');

subplot(3,2,5); plot2d3(n1,y5);
xlabel('time'); ylabel('amplitude');
title('Addition of Signals');

subplot(3,2,6); plot2d3(n1,y6);

xlabel('time');
ylabel('amplitude');
title('Multiplication of Signals');

// Energy and Average power of a signal t


= 0:0.01:4; s = cos(2*
%pi*t); M = length(s);
disp(M)sum = 0; for i=
1:M, sum=sum+(i*i);
end;
disp('Energy of the given signal is .......... :: ');
Energy = sum disp(Energy)
disp('Average Power of the given signal is .......... :: ');
Average_power= sum/M disp(Average_power)

OUTPUT:
Enter the sequence 1=[1 2 3]
Enter the sequence 2=[2 3 4 5]

Addition result of two unequal length sequences:= 3.


5. 7. 5.

Enter the sequence 1=[1 2 3]


Enter the sequence 2=[2 3 4 5]
Multiplication result of two unequal lengths equences:= 2.
6. 12. 0.
Enter the input sequence e := [1 2 3 4 5] Enter the
starting point of original signal=2

Enter input Sequence : = [5 6 7 8 9] Enter starting point


of original signal:= 5
Enter Compression factor Time Scaling factor 5
Enter the input sequence := [5 6 7 8 9]
Enter the starting point of original signal: = 5
Enter the d e l a y: = 2

Enter the sequence ...:: [3 4 5 6 7]


5.
Energy of the given sequence is ......... ::
55.
Average Power of the given sequence is .......... ::
11.
CONCLUSION: -

EXPERIMENT -5

AIM: Generation of Gaussian distribution length 1000random sequence .compute the mean and
variance of the random signal by a suitable method.

SOFTWARE REQUIRED: PC loaded with 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.
PROCEDURE:
1. Click on MATLAB Icon
2. Type the program on editor window
3. Save the program
4. Execute the program and observe the output/wave forms

.PROGRAM:
clc;
clear all;
close all;
N= input(' Enter the number of samples........ :: ');
R1=randn(1,N);
M=mean(R1);
K=kurtosis (R1);

P=periodgram(R1);
V=var(R1);
x = psd(R1);

subplot(2,2,1); plot(R1);
xlabel('Sample
Number');
ylabel('Amplitude');
title('Normal [Gaussian] Distributed Random Signal');

subplot(2,2,2);
hist(R1);
xlabel('Sample Number');
ylabel('Total');
title('Histogram [Pdf] of a normal Random Signal');

subplot(2,2,[3,4]);
plot(x);
xlabel('Sample Number'); ylabel('Amplitude');
title('PSD of a normal Random Signal');

OUTPUT:
CONCLUSION: -
EXPERIMENT NO- 06

AIM OF THE EXPERIMENT:-


To get linear convolution of any two given sequences using matlab.
EQUIPMENTS &SOFTWARE REQUIRED:-
i) Matlab R2010A
ii) Personal Computer

THEORY:
The formula that gives the response y(n) of the LTI system as a function of the input signal x(n) and
the unit sample (impulse) response h(n) is called a convolution sum.We say that the input x(n) is
convoluted with the impulse response h(n) to yield the output y(n).
Convolution between x(n) and h(n) is represented as y(n)=x(n)*h(n),where ‘*’ denotes convolution
operation.
Mathematically convolution is represented as


y(n)= ∑ x(k)h(n-k)

k=-∞

Process to compute convolution :-

i) Folding- Fold h(k) about k=0 to obtain h(-k)


ii) Shifting- Shift h(-k) by n0 to right (left) if n0 is positive(negative),to get h(n0 -k)
iii) Multiplication- Multiply x(k) by h(n0 -k) to obtain product sequence
vn0 (k) =x(k) h(n0 -k)
iv) Summation:- Sum all the values of the product sequence vn0 (k) to obtain the value of
the output at time n= n0
Properties of convolution:-

i) Commutative law-
x(n)*h(n)=h(n)*x(n)
ii)Associative law-
[ x(n)*h1(n)]*h2(n)= x(n)*[h1(n)*h2(n)]
iii)Distributive law-
x(n)*[h1(n)+h2(n)]= x(n)*h1(n)+x(n)*h2(n)

PROGRAM: -
clc
clear all
x=input('enter the 1st seq')
h=input('enter the second seq')
m=length(x)
p=length(h)
n=m+p-1
x=[x,zeros(1,p-1)]
z=zeros(1,p)
for i=1:n

for j=p:-1:2
z(j)=z(j-1)
end
z(1)=x(i)
sum=0
for k=1:p;
sum=sum+z(k)*h(k)
end
y(i)=sum
end
disp('the result is');y
subplot(3,1,1)
stem(x)
xlabel('time')
ylabel('amp')
title('x(n)')
subplot(3,1,2)
stem(h)
xlabel('time')
ylabel('amp')
title('h(n)')
subplot(3,1,3)
stem(y)
title('y(n)')
PLOTS FOR LINEAR CONVOLUTION

CONCLUSION: -

We got the result of linear convolution of two sequences and printed the output
EXPERIMENT NO- 07

AIM OF THE EXPERIMENT:


Comparison between linear and circular convolution of two sequences using
Mat lab.

OBJECTIVES:-
i) To generate two sequences x1 & x2 containing a number of samples.
ii) To find circular convolution between x1 &x2 using function file and script file.
iii) To find linear convolution between the same two sequences.
iv) To plot both linear and circular convolution.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer

THEORY
Linear Convolution-
i) If x(n) has ‘l’ samples and h(n) has’m’samples then y(n) result has ‘m+l-1’ number of
samples.
ii) There is no modulo-N operation.
iii) It is used to find the response of a filter.

Circular convolution-
i) Here output y(n) has max(l,m) number of samples .
ii) Shifting operation is done here in circular manner by computing index of one
iii) sequense modulo N.
iv) It cann’t be used to find response of a filter without zero padding.

PROGRAM
% FUNCTION FILE
function y=my_circonv(x1,x2)%function file declaration
%This gives circular convolution of x1,x2
%To call this:-y=my_circonv(x1,x2)
%The file is stored under the function name(my_circonv)
%y=output,x1=input,x2=input
n1=length(x1)
n2=length(x2)
n=max(n1,n2)
n3=n1-n2
if n3>0
x2=[x2,zeros(1,n3)]
else
x1=[x1,zeros(1,-n3)]
end
for a=1:n
y(a)=0
for i=1:n
j=a-i+1
if(j<=0)
j=n+j
end
y(a)=y(a)+(x1(i)*x2(j))
end
end
disp('result is');y

%SCRIPT FILE
%Comparision between circular & linear convolution
%This is a script file

x1=input('enter the first sequrnce')


x2=input('enter the second sequence')
x3=conv(x1,x2)
x4=my_circonv(x1,x2)%The function file is called here
%function file is stored under the name my_circonv
subplot(2,1,1)
stem(x3)
xlabel('n')
ylabel('y(n)')
title('linear convolution')
subplot(2,1,2)
stem(x4)
xlabel('n')
ylabel('x3(n)')
title('circular conv')
PLOTS FOR CIRCULAR CONVOLUTION VS LINEAR CONVOLUTION

CONCLUSION: -

We got the result of linear convolution of two sequences and circular convolution of two sequences
and printed the both.
EXPERIMENT NO- 08

AIM OF THE EXPERIMENT:


To perform cross correlation of any two sequences using mat lab.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer
THEORY:
Cross correlation- Suppose we have two real signal sequences x(n) and y(n) each of which has finite
energy(3 here).The cross correlation of x(n) and y(n) is a sequence r xy(l),which is defined as n=∞

rxy(l)= ∑x(n)y(n-l) l=0,±1, ±2,…

n=-∞

or equivalently as as
n=∞

rxy(l)= ∑x(n+l)y(n) l=0,±1, ±2,…

n=-∞

The index l is the (time) shift(or lag) parameter and subscripts xy in the cross correlation sequence
rxy(l) indicate the sequences being correlated.The order of subscripts with x proceeding y,indicates the
direction in which one sequence is shifted related to the other.

Properties-
rxy(l)= ryx(-l)
Relation between convolution and correlation-
rxy(l)= x(l)*y(l)

PROGRAM:-

%Cross correlation between two sequence


clc
clear all
x=input('enter the first sequence')
y=input('enter the second sequence')
r=xcorr(x,y)
subplot(3,1,1)
stem(x)
xlabel('n')
ylabel('x(n)')
title('input x(n)')
subplot(3,1,2)
stem(y)
xlabel('n')
ylabel('y(n)')
title('input y(n)')
subplot(3,1,3)
stem(r)
xlabel('n')
ylabel('rxy(l)')
title('cross correlation')

PLOTS FOR CROSS CORRELATION

CONCLUSION: -
We got the cross correlation of two sequences and the output is printed.
EXPERIMENT NO- 09

AIM OF THE EXPERIMENT:


To perform auto correlation of any two sequences using matlab.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer
THEORY:
Auto Correlation- The autocorrelation of a sequence is a correlation of a sequence with itself.The
autocorrelation of a sequence x(n) is defined by
n=∞

rxx(l)= ∑x(n)x(n-l) l=0,±1, ±2,…

n=-∞

or equivalently
n=∞

rxx(l)= ∑x(n+l)x(n) l=0,±1, ±2,…

n=-∞

Properties-

rxx(l)= rxx(-l)
Relation between convolution and correlation-

rxx(l)=x(l)*x(-l)

PROGRAM:-

%Auto correlation between two sequence


clc
clear all
x=input('enter the input sequence')
r=xcorr(x,x)
subplot(2,1,1)
stem(x)
xlabel('n')
ylabel('x(n)')
title('input x(n)')
subplot(2,1,2)
stem(r)
xlabel('n')
ylabel('rxy(l)')
title('Auto correlation')
PLOTS FOR AUTO CORRELATION

CONCLUSION: -

We got the auto correlation of two sequences and the output is printed.
EXPERIMENT NO- 10

AIM OF THE EXPERIMENT:


Program for Probability density function using matlab.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer
THEORY:
The discrete binomial pdf assigns probability to the event of k successes in n trials of a
Bernoulli process (such as coin flipping) with probability p of success at each trial. Each of the
integers k = 0, 1, 2, ..., n is assigned a positive probability, with the sum of the probabilities
equal to 1.

PROGRAM:-
p = 0.2; % Probability of success for each trial
n = 10; % Number of trials
k = 0:n; % Outcomes
m = binopdf(k,n,p); % Probability mass vector
bar(k,m) % Visualize the probability distribution
set(get(gca,'Children'),'FaceColor',[.8 .8 1])
grid on

CONCLUSION: -

We got the Probability density function using matlab.

You might also like