DSP File
DSP File
DSP File
Experiment No.- 2
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
exists for t > 0 and zero for t < 0. If a step signal has unity magnitude, then it is known as unit step
signal or unit step function. It is denoted by u(t).
{
U (t )= 1 , t ≥ 0
0 ,∧t <0
Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.
Program:
t = -20 : 0.001 : 20;
y = heaviside(t);
plot(t, y, ‘Linewidth’, 3)
axis([-10 10 -2 2])
xlabel(‘t’)
ylabel(‘u(t)’)
Experiment No.- 2
Representation:
Experiment No.- 3
Theory:
The step sequence is that type of standard signal which exists only for positive discrete instants
and it is zero for negative discrete instants. In other words, a sequence u(n) is said to be step
sequence if and only if exists for n ≥ 0 and zero for n < 0. If a step sequence has unity magnitude,
then it is known as unit step sequence. It is denoted by u(n).
{
U ( n)= 1 ,n ≥ 0
0 ,∧n< 0
Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.
Program:
n = -10 : 20;
s = [ zeros(1,10) ones(1,21)];
stem(n, s);
xlabel(‘n’);
ylabel(‘u(n)’);
axis([-10 20 0 1.2]);
Experiment No.- 3
Representation:
Experiment No.- 4
Theory:
The discrete time unit ramp signal is that function which starts from n = 0 and increases
linearly. It is denoted by r(n). It is signal whose amplitude varies linearly with time n.
Mathematically, the discrete time unit ramp sequence is defined as-
{
r ( n ) = n ,∧for n ≥0
0 ,∧for n< 0
Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.
Program:
Experiment No.- 5
Theory:
The discrete time unit impulse sequence δ (n), also called the unit Sample sequence, is
defined as,
{
δ ( n )= 1 , for n=0
¿ 0 , for n≠ 0
Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.
Program:
n = -20:20;
stem(n,delta_n)
xlabel(“n”);
ylabel(“Amplitude”);
Experiment No.- 6
Theory:
In MATLAB we can add or subtract discrete time signals to study them.
Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.
Program:
sequence1 = [1, 2, 3, 4, 5];
if length(sequence1) ~= length(sequence2)
end
figure;
subplot(3, 1, 1);
title('Sequence 1');
xlabel('Index');
ylabel('Value');
subplot(3, 1, 2);
title('Sequence 2');
xlabel('Index');
ylabel('Value');
subplot(3, 1, 3);
title('Result');
xlabel('Index');
ylabel('Value');
Representation:
Experiment No.- 7
Theory:
In mathematics and signal processing, the Z-transform converts a discrete-time signal,
which is a sequence of real and complex numbers, into a complex frequency-domain
representation.
Where z = rejw is a complex variable. The value of z for which the sum converges define a region
in the Z-plane referred to as the region of convergence(ROC).
Procedure:
Program:
Method-I (Using for loop) Method-II (Using Z-transform function)
X = [1 2 3 4 5]; syms n
L = length(x); f = sin(n);
Z = sym(‘Z’);s r = ztrans(f);
for i = 0:L-1 disp(‘Z-transform using function’);
X = X + X(i+1)*Z-i; disp(r);
end
disp(‘displaying output’);
disp(X);
Representation:
Experiment No.- 8
Theory:
Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.
Program:
syms n
f = sin(n);
z = ztrans(f);
disp(‘ztransform of sin(n) is’);
disp(z);
zz = iztrans(z);
disp(‘displaying inverse z transform);
disp(zz);
Representation:
Experiment No.- 9
Theory:
In case of convolution two signal sequences input signal x(n) and impulse response h(n)
given by the same system, output y(n) is calculated by multiplication of two sequences in time
domain is called as Linear Convolution.
Linear Convolution is given by the equation
y(n) = x(n)*h(n)
and calculated as,
∞
❑
y (n) = ∑ ❑
x ( k ) h(n−k )
k =−∞
Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.
Program:
x1 = [1 2 3 4];
x2 = [2 4 3 1 5 6 8];
y = conv(x1,x2);
subplot(311)
stem(‘x1’)
xlabel(‘n’);
ylabel(‘x1[n]’);
title(‘vector x1’)
subplot(312)
stem(‘x2’)
xlabel(‘n’);
Representation:
Experiment No.- 10
Theory:
DFT- The N-point DFT of a finite duration sequence of length L, where N≥L is defined
as,
DFT ¿ ;k=0,1,2,…..,N-1
IDFT- The Inverse Discrete Fourier Transform of sequence X(k) of length N is defined
as:
N−1 j2πnk
1
IDFT [ X ( K ) ] =x ( n )=
N
∑ X (k )e N
; n= 0,1,2,….,N-1
k=0
Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.
Program:
xn = input(‘Enter the input sequence’)
n = length(xn)
n =0:1:N-1;
subplot(2,2,1)
stem(n,xn)
xlabel(‘time’)
ylabel(‘amplitude’)
title(‘Input sequence’)
xk = fft(xn,N)
disp(kx)
k=0:1:N-1;
subplot(2,2,2)