0% found this document useful (0 votes)
19 views

Matlab File Vikash

The document discusses experiments in MATLAB to visualize and compute various signal processing concepts like the unit step function, unit impulse function, discrete Fourier transform, circular convolution, and linear convolution. Code snippets and explanations are provided for MATLAB implementations of these signal processing topics.

Uploaded by

vipako9305
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Matlab File Vikash

The document discusses experiments in MATLAB to visualize and compute various signal processing concepts like the unit step function, unit impulse function, discrete Fourier transform, circular convolution, and linear convolution. Code snippets and explanations are provided for MATLAB implementations of these signal processing topics.

Uploaded by

vipako9305
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Digital Processing Lab

(MATLAB FILE)
B.TECH SEMESTER – VI
(Code: BECC-0805)

NAME- Vikash Varshney


SECTION- C
ROLL NO.- 33
UNIVERSITY ROLL NO.- 2113100030

Department of Electronics and Communications


GLA UNIVERSTIY, MATHURA
EXPERIMENT 1

Objective: To plot the unit impulse and unit step function using MATLAB.

Software Required: MatlabR2018a

Theory: The step signal or step function is that type of standard signal which exists only for
positive time and it is zero for negative time. In other words, a signal x(t) is said to be step signal
if and only if it exists for t > 0 and zero for t < 0. The step signal is an important signal used for
analysis of many systems.

u(t)= {1, t≥0

0, t<0}

An ideal impulse signal is a signal that is zero everywhere but at the origin (t = 0), it is infinitely
high. Although, the area of the impulse is finite. The unit impulse signal is the most widely used
standard signal used in the analysis of signals and systems.

δ(t)= {1, t=0

0, t ≠ 0}

Source code:
clc; close
all; clear
all; n = -
3:3;
x= [zeros (1,3) 1 zeros (1,3)];
subplot (2,2,1); stem (n, x);
xlabel ('time ----->');
ylabel('amplitude');
title ('unit impulse function'); %---------------------------------------
N=input ('enter the value');
n=0: N-1; x=ones (1, N);
subplot (2,2,4); stem(n,x);
xlabel ('time ----->');
ylabel('amplitude'); title
('unit STEP function');
Simulation results:

Conclusion: The unit impulse and unit step function have been plotted using MATLAB.
EXPERIMENT 2

Objective: To compute the 4-point DFT of an input sequence.

Software Required: MatlabR2018a

Theory: The discrete Fourier transform (DFT) converts a finite sequence of equally spaced
samples of a function into a same-length sequence of equally-spaced samples of the discrete-time
Fourier transform (DTFT), which is a complex-valued function of frequency. The interval at which
the DTFT is sampled is the reciprocal of the duration of the input sequence. The DFT is therefore
said to be a frequency domain representation of the original input sequence.

Source code:
clc; close all; clear all;
x = input('enter the four point sequence');
function X = DFT(x,N);
j = sqrt(-1);
N = numel(x);
X = zeros(1,N);
for K = 1:N
s = 0;
for n =1:N
s =s + x(n)*exp(-j*((2*pi)/N)*(n-1)*(K-1));
end
X(K) = s;
end
%calculating the magnitude
X_mag= abs(X);
% calculating the phase
X_real = real(X);
X_img = imag(X);
X_phase = atan(X_img./X_real);
%plotting the magnitude spectrum
subplot(2,1,1);
stem(X_mag);
title('magintude spectrum');
subplot(2,1,2);
stem(X_phase);
title('phase spectrum');
Simulation results: x(n)=[1 0 -1 1]

Conclusions: The 4-point DFT have been plotted using MATLAB.


EXPERIMENT 3

Objective: To compute and plot 4-point Circular Convolution using MATLAB

Software Required: MATLAB R2018a

Theory: Circular convolution, also known as cyclic convolution, is a special case of periodic
convolution, which is the convolution of two periodic functions that have the same period.
Periodic convolution arises, for example, in the context of the discrete-time Fourier transform
(DTFT).
Generally, there are two methods, which are adopted to perform circular convolution and
they are −
• Concentric circle method,
• Matrix multiplication method.

Source Code:

clc ; clear all; close all;


x1=input ('Enter the Sequence 1');
x2=input ('Enter the Sequence 2');
N=numel(x1);
subplot(3,1,1);
stem(x1);
xlabel('n -->');
ylabel('x1 -->');
title('Sequence 1');
subplot(3,1,2);
stem(x2);
xlabel('n -->');
ylabel('x2 -->');
title('Sequence 2');
% Calling user-defined function DFT
X1=DFT(x1,N);
X2=DFT(x2,N);
Y= X1.*X2;
Circ_conv=ifft(Y);
% X_mag=abs(Circ_conv);
subplot(3,1,3)
stem(Circ_conv);
xlabel('n -->');
ylabel('Y -->');
title('Circular Convolution');
% DFT function is defined
function X=DFT(x,N)
j=sqrt(-1);
X=zeros(1,N);
for k=1:N
s=0;
for n=1:N
s=s+(x(n)*exp(-j*(2*pi/N)*(n-1)*(k-1)));
end
X(k)=s;
end

Inputs:

X1 : [1 2 3 4]

X2: [1 -1 1 -1]

Simulation Results:

Conclusion:

The Circular Convolution of Two Sequences have been obtained using MATLAB.
EXPERIMENT 4
Objective: To compute and plot Linear Convolution of input sequence using MATLAB.

Software Required: MATLAB 2018A

Theory: Convolution is a mathematical operation on two functions (f and g) that produces a


third function. 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 reflected
about the y-axis and shifted. The integral is evaluated for all values of shift, producing the
convolution function. The choice of which function is reflected and shifted before the integral
does not change the integral result. Graphically, it expresses how the 'shape' of one function is
modified by the other.
The convolution of f and g is written f*g, denoting the operator symbol *. It is defined as the
integral of the product of two functions after one is reflected about y-axis and shifted. As such, it
is a particular kind of integral transform:

Source Code:

clc; close all; clear all;


x=input('enter the first sequence');
y=input('enter the second sequence');
c=conv(x,y);
subplot(3,1,1);
stem(x);
xlabel('n');
ylabel('x');
title('plot of x');
subplot(3,1,2);
stem(y);
xlabel('n');
ylabel('y');
title('plot of y');
subplot (3,1,3);
stem(c);
xlabel('n');
ylabel('linearconv');
title('linear convolution');
Simulation Results:

Conclusion:

The Linear Convolution of 2-input sequences is obtained and plotted using MATLAB.

You might also like