Experiment 1:
Title: Impulse and step response of the discrete systems.
Objective: To Find out the impulse and step response of the systems described as
Theory:
• The impulse response of a system is the output of the system when the input is an impulse, δ(t), and
all initial conditions are zero.
• The step response of a system is the output of the system when the input is a step, H(t), and all
initial conditions are zero.
Matlab programs:
1st question
clc; % Clear the command window
close all; % Close all open figure windows
clear all; % Remove all variables from the workspace
N = 40; % Define the number of samples for the impulse and step responses
num = [1 0 0]; % Numerator coefficients of the transfer function (z^2 term only)
den = [1 -0.6 0.08]; % Denominator coefficients of the transfer function
% Compute the impulse response of the system
[h, t] = impz(num, den, N); % h = impulse response, t = time index vector (0 to N-1)
figure; % Create a new figure window
stem(t, h); % Plot the impulse response using a stem plot
title('Impulse Response'); % Title of the plot
xlabel('n'); % X-axis label for discrete time index
ylabel('h[n]'); % Y-axis label for impulse response values
% Create a discrete-time transfer function system
sys = tf(num, den, -1); % 'tf' creates the transfer function; -1 means discrete with
unspecified sample time
% Compute the step response of the system over N samples
[y_step, t_step] = step(sys, N); % y_step = step response, t_step = time index vector
figure; % Create another new figure window
stem(t_step, y_step); % Plot the step response using a stem plot
title('Step Response'); % Title of the step response plot
xlabel('n'); % X-axis label for discrete time index
ylabel('y[n]'); % Y-axis label for step response values
2nd question
clc; % Clear the command window
close all; % Close all open figure windows
clear all; % Clear all variables from the workspace
N = 40; % Define the number of samples for impulse and step responses
% Define the numerator and denominator of the transfer function
num = [0.2762 -0.7236 0]; % Numerator coefficients of the transfer function
den = [1 -1 -0.9999]; % Denominator coefficients of the transfer function
% Compute the impulse response of the system
[h, t] = impz(num, den, N); % h = impulse response, t = sample indices (from 0 to N-1)
% Plot the impulse response
figure; % Open a new figure window
stem(t, h); % Use stem plot for the discrete impulse response
title('Impulse Response'); % Title of the plot
xlabel('n'); % X-axis label (discrete time index)
ylabel('h[n]'); % Y-axis label (impulse response values)
% Define the system transfer function
sys = tf(num, den, -1); % Create discrete-time transfer function (-1 indicates unspecified sample
time)
% Compute the step response of the system
[y, t_step] = step(sys, N); % Compute step response y over N samples with time index t_step
% Plot the step response
figure; % Open a new figure window
stem(t_step, y); % Use stem plot for the discrete step response
title('Step Response'); % Title of the plot
xlabel('n'); % X-axis label (discrete time index)
ylabel('y[n]'); % Y-axis label (step response values)
Conclusion: The impulse and step responses of discrete systems provide essential insights into their behavior and
stability. The impulse response shows how the system reacts to a single input, while the step response reveals how it
behaves over time. Together, they help determine whether the system is stable, causal, and how it responds to
different inputs—making them crucial tools in system analysis and design.
Experiment 2:
Title: VERIFICATION OF SAMPLING THEOREM
Objective: To verify the SAMPLING THEOREM
Theory:
Sampling: Is the process of converting a continuous time signal into a discrete time signal. It is the first step in
conversion from analog signal to digital signal.
Sampling theorem: Sampling theorem states that “Exact reconstruction of a continuous time base-band signal from
its samples is possible, if the signal is band-limited and the sampling frequency is greater than twice the signal
bandwidth” i.e. fs > 2W, where W is the signal bandwidth.
Nyquist Rate Sampling: The Nyquist rate is the minimum sampling rate required to avoid aliasing, equal to the highest
modulating frequency contained within the signal. In other words, Nyquist rate is equal to two-sided bandwidth of
the signal (Upper and lower sidebands). To avoid aliasing, the sampling rate must exceed the Nyquist rate. i.e. fs > fn.
Matlab program:
% Sine signal and aliasing
fy=3; %signal frequency in Hz
wy=2*pi*fy; %signal frequency in rad/s
% good sampling frequency
clc;
fs=100; %sampling frequency in Hz
tiv=1/fs; %time interval between samples;
t=0:tiv:(3-tiv); %time intervals set
y=sin(wy*t); %signal data set
subplot(4,1,1); plot(t,y,'k'); %plots figure
axis([0 3 -1.5 1.5]);
title('3Hz sine signal');
ylabel('fs=100');
% too slow sampling frequency
fs=4; %sampling frequency in Hz
tiv=1/fs; %time interval between samples;
t=0:tiv:(3-tiv); %time intervals set
y=sin(wy*t); %signal data set
subplot(4,1,2); plot(t,y,'-kd'); %plots figure
axis([0 3 -1.5 1.5]);
xlabel('seconds');
ylabel('fs=4');
% too slow sampling frequency
fs=10; %sampling frequency in Hz
tiv=1/fs; %time interval between samples;
t=0:tiv:(3-tiv); %time intervals set
y=sin(wy*t); %signal data set
subplot(4,1,3); plot(t,y,'-kd'); %plots figure
axis([0 3 -1.5 1.5]);
xlabel('seconds');
ylabel('fs=10');
% too slow sampling frequency
fs=60; %sampling frequency in Hz
tiv=1/fs; %time interval between samples;
t=0:tiv:(3-tiv); %time intervals set
y=sin(wy*t); %signal data set
subplot(4,1,4); plot(t,y,'-kd'); %plots figure
axis([0 3 -1.5 1.5]);
xlabel('seconds');
ylabel('fs=60');
Conclusion:
The experiment verifies the Sampling Theorem by demonstrating that a continuous-time signal can be accurately
reconstructed from its samples only when the sampling frequency is greater than twice the signal bandwidth. If the
sampling frequency is below this threshold, aliasing occurs, making reconstruction impossible. This confirms the
necessity of sampling at or above the Nyquist rate to ensure faithful reproduction of the original analog signal.
Experiment 2:
Title: Generate different signals using MATLAB
Obj:
Programs:
1. Unit impulse signal
clc; % Clear the command window
clear all; % Clear all variables from the workspace
close all; % Close all figure windows
disp('UNIT IMPULSE SIGNAL'); % Display a message on the console
N = input('Enter Number of Samples: '); % Prompt the user to enter number of samples on one side
n = -N:1:N; % Define time index from -N to +N
x = [zeros(1, N), 1, zeros(1, N)]; % Create unit impulse signal (1 at n=0, zeros elsewhere)
stem(n, x); % Plot the impulse signal using a stem plot
xlabel('Time'); % Label for x-axis
ylabel('Amplitude'); % Label for y-axis
title('Impulse Signal'); % Title of the plot
Output:-
'UNIT IMPULSE SIGNAL'
2. Unit step signal
clc; % Clear the command window
clear all; % Clear all variables from the workspace
close all; % Close all figure windows
disp ('UNIT STEP SIGNAL'); % Display a title message
N = input('Enter Number of Samples: '); % Prompt user to enter number of samples on each side
n = -N:1:N; % Time index vector from -N to N
x = [zeros(1, N), 1, ones(1, N)]; % Create unit step signal: 0 for n<0, 1 at n=0, and 1 for n>0
stem(n, x); % Plot the unit step signal using a stem plot
xlabel('Time'); % Label for x-axis
ylabel('Amplitude'); % Label for y-axis
title('Unit Step Signal'); % Title of the plot
Output:-
UNIT STEP SIGNAL
Number of Samples : 6
3. Unit ramp signal
clc; % Clear the command window
clear all; % Clear all variables from the workspace
close all; % Close all figure windows
disp('UNIT RAMP SIGNAL'); % Display a title message
N = input('Enter Number of Samples: '); % Prompt user to enter number of ramp samples
a = input('Enter Amplitude: '); % Prompt user to enter ramp amplitude (slope)
n = 0:1:N; % Define time index from 0 to N (ramp starts at n=0)
x = a * n; % Compute ramp signal: x[n] = a * n
stem(n, x); % Plot the unit ramp signal using a stem plot
xlabel('Time'); % Label for x-axis
ylabel('Amplitude'); % Label for y-axis
title('Unit Ramp Signal'); % Title of the plot
Output:-
UNIT RAMP SIGNAL
Enter Number of Samples: 6 Enter
Amplitude: 20
4. Exponential decaying signal
clc; % Clear the command window
clear all; % Clear all variables from the workspace
close all; % Close all figure windows
disp('EXPONENTIAL DECAYING SIGNAL'); % Display a title message
N = input('Enter Number of Samples: '); % Prompt user to enter the maximum time value
a = 0.5; % Decay factor (0 < a < 1 for exponential decay)
n = 0:0.1:N; % Define time index with finer resolution (step = 0.1)
x = a .^ n; % Generate exponentially decaying signal: x[n] = a^n
stem(n, x); % Plot the signal using a stem plot
xlabel('Time'); % Label for x-axis
ylabel('Amplitude'); % Label for y-axis
title('Exponential Decaying Signal'); % Title of the plot
output
'EXPONENTIAL DECAYING SIGNAL'
Enter Number of Samples: 6
5. Exponential growing signal
clc; % Clear the command window
clear all; % Clear all variables from the workspace
close all; % Close all figure windows
disp('EXPONENTIAL GROWING SIGNAL'); % Display a title message
N = input('Enter Number of Samples: '); % Prompt the user to enter number of samples
a = 0.5; % Base value (0 < a < 1 for exponential growth when raised to -n)
n = 0:0.1:N; % Define time index from 0 to N with step size 0.1
x = a .^ (-n); % Generate exponentially growing signal: x[n] = a^(-n)
stem(n, x); % Plot the signal using a stem plot (discrete signal)
xlabel('Time'); % Label for x-axis
ylabel('Amplitude'); % Label for y-axis
title('Exponential Growing Signal'); % Title of the plot
Output:-
E XPON NTIAL GROWING SIGNAL
Number of Samaples : 6
6. Cosine signal
clc; clear all; close all;
disp (' COSI NE SIGNAL ');
N= input (' Enter Number of Samples: '); n= 0: 0. 1:N
x=cos (n) stem (n, x);
xlabel ('Time') ;
ylabel ('Amplitude');
title ('Cosine Signal');
Output:-
COSINE SIGNAL
Enter Number of Samaples : 16
7. Sine signal
dis p ('SINE SIGNAL ');
N= input (' Enter Number of Samples: ');
n= 0:0. 1:N
x=sin( n) ;
stem (n,x);
xlabel ('Time') ; ylabel (' Amplitude'); title('sine Signal');
Output:-
SINE SIGNAL
Enter Number of Samples : 16
8.sawtooth Signal generation
%sawtooth signal to be analyzed
clc;
close all;
fy=1; %signal frequency in Hz
wy=2*pi*fy; %signal frequency in rad/s
Ty=1/fy; %signal period in seconds
N=256;
fs=N*fy; %sampling frequency in Hz
tiv=1/fs; %time interval between samples;
t=0:tiv:((3*Ty)-tiv); %time intervals set (3 periods)
y3=sawtooth(wy*t); %signal data set
plot(t,y3,'k');
xlabel('seconds'); title('sawtooth signal (3 periods)');
Output:
9.Generation of amplitude modulated signal
Amplitude modulation is a process by which the wave signal is transmitted by modulating the amplitude of the
signal. It is often called AM and is commonly used in transmitting a piece of information through a radio carrier wave.
Amplitude modulation is mostly used in the form of electronic communication.
Program:
clear all; close all;
clc;
t = 0:0.001:5; %time.
fm = 1; %frequency of message signal.
fc = 10; %frequency of carrier signal.
fs=100*fc; %sampling frequency.
Am = 5; %Amplitude of message signal.
Ac = 5; %Amplitude of carrier signal.
msg =Am.*cos(2*pi*fm*t); %message signal.
carrier = Ac.*cos(2*pi*fc*t); %carrier signal.
%% DSB SC MODULATION AND DEMODULATION.
%===========DSB SC IN TIME DOMAIN==================
dsb_sc = msg.*carrier; %dsbsc modulated wave
%=====DSB SC DEMODULATION TIME DOMAIN============
pmo = 2*dsb_sc.*carrier; %product modulator output
pmo = pmo/Ac;
nf = fm/fs; %normalised frequency
[num, den] = butter(5,3*nf); %butter worth lpf of 5th order
msg_r = filter(num,den,pmo); %demodulated signal after passing through lpf
%================ PLOTTING %%=========================
subplot(4,1,1);
plot(t, msg);
title("MESSAGE SIGNAL (TIME DOMAIN)");
xlabel('time (sec)');
ylabel('amplitude');
gridon;
subplot(4,1,2);
plot(t, carrier);
title("CARRIER SIGNAL (TIME DOMAIN)");
xlabel('time (sec)');
ylabel('amplitude');
gridon;
subplot(4,1,3);
plot(t, dsb_sc);
title("MODULATED DSB SC SIGNAL (TIME DOMAIN)");
xlabel('time (sec)');
ylabel('amplitude');
gridon;
subplot(4,1,4);
plot(t, msg_r);
title("DEMODULATED DSB SC SIGNAL (TIME DOMAIN)");
xlabel('time (sec)');
ylabel('amplitude');
gridon;
output:
10.Frequency modulated signal using.
Frequency modulation is a technique or a process of encoding information on a particular signal (analogue or digital)
by varying the carrier wave frequency in accordance with the frequency of the modulating signal.
Program:
fm=25;
fc=400;
B=10
t=0:0.0001:0.5;
m=cos(2*pi*fm*t);
subplot(3,1,1);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;
c=cos(2*pi*fc*t);
subplot(3,1,2);
plot(t,c);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
grid on;
y=cos(2*pi*fc*t+(B*sin(2*pi*fm*t)));
subplot(3,1,3);
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
title('FM Signal');
grid on;
output/;
Conclusion:
In this experiment, various basic discrete-time signals such as the unit impulse, unit step, unit ramp, and
exponentially decaying signals were generated and visualized using MATLAB. Each signal was defined mathematically
and implemented through vector operations and stem plots for discrete representation. The practical
implementation of these signals helped in understanding their characteristics and behavior in time domain. This
experiment reinforced foundational concepts of signal processing and provided hands-on experience in MATLAB
programming for signal analysis.
Experiment: 4
Title: Study the cross-correlation and auto-correlation of two signals.
Theory :
Correlation: Correlation determines the degree of similarity between two signals. If the signals are identical, then the
correlation coefficient is 1; if they are totally different, the correlation coefficient is 0, and if they are identical except
that the phase is shifted by exactly 1800(i.e. mirrored), then the correlation coefficient is -1.
4.1. program
% Program for computing cross-correlation of the sequences
% Example: x = [1, 2, 3, 4]; h = [4, 3, 2, 1];
clc; % Clear the command window
clear all; % Clear all variables from the workspace
close all; % Close all figure windows
% Input two sequences from the user
x = input('Enter the 1st sequence x[n]: '); % e.g., [1, 2, 3, 4]
h = input('Enter the 2nd sequence h[n]: '); % e.g., [4, 3, 2, 1]
% Compute cross-correlation between x and h
y = xcorr(x, h); % Cross-correlation of x and h
% Plot the input and resulting sequences
figure; % Open new figure window
subplot(3,1,1); % First subplot: sequence x
stem(x);
ylabel('Amplitude');
xlabel('(a) n');
title('Sequence x[n]');
subplot(3,1,2); % Second subplot: sequence h
stem(h);
ylabel('Amplitude');
xlabel('(b) n');
title('Sequence h[n]');
subplot(3,1,3); % Third subplot: cross-correlation result
stem(fliplr(y)); % Flip the result for viewing, if desired
ylabel('Amplitude');
xlabel('(c) n');
title('Cross-Correlation Output');
% Display the output values
disp('The resultant cross-correlation signal is:');
fliplr(y) % Display flipped result in the console
4.2) Auto Correlation for the given sequence
% Auto Correlation for the given sequence
clc; % Clear command window
close all; % Close all figure windows
clear all; % Clear all variables from workspace
x = input('Enter the sequence x[n]: '); % Input the sequence, e.g., [1 2 4 3]
y = xcorr(x, x); % Auto-correlation of x with itself
% Plotting
figure;
subplot(2,1,1); % First subplot: input sequence
stem(x);
ylabel('Amplitude →');
xlabel('n →');
title('Input Sequence x[n]');
subplot(2,1,2); % Second subplot: auto-correlation result
stem(y); % Use y directly (no need to flip)
ylabel('Amplitude →');
xlabel('Lag →');
title('Auto-Correlation Sequence');
% Display the result
disp('The auto-correlation result is:');
disp(y); % Display correlation vectorInput: Enter the sequence 1:
[1 2 4 3]
Output:
Conclusion
Auto-correlation helps identify repeating patterns within a signal, while cross-correlation measures the similarity
between two signals, often used to detect time delays or alignment. Both are essential tools in signal analysis, with
broad applications in communications, control, and pattern recognition.
Experiment 5:
Title: Implementation of FFT
Program:
clear all; % Clear all variables from workspace
N = 8; % Length of the input sequence
m = 8; % Number of DFT points (usually same as N)
a = input('Enter the input sequence: '); % User input for the sequence
n = 0:1:N-1; % Time index for original sequence
% Plot the input sequence
subplot(2,2,1);
stem(n, a);
xlabel('Time Index n');
ylabel('Amplitude');
title('Input Sequence');
% Compute the FFT of the input sequence
x = fft(a, m);
k = 0:1:N-1; % Frequency index
% Plot the magnitude of the DFT
subplot(2,2,2);
stem(k, abs(x));
ylabel('Magnitude');
xlabel('Frequency Index K');
title('Magnitude of the DFT');
% Plot the phase of the DFT
subplot(2,2,3);
stem(k, angle(x));
xlabel('Frequency Index K');
ylabel('Phase (radians)');
title('Phase of the DFT');
Output:-
Enter the input sequence[1 1 1 1 0 0 0 0]
5B
Title: Discrete Fourier Transform (DFT)
Program:
clc; % Clear the command window
% Get input sequence and its length from the user
x1 = input('Enter the sequence: ');
n = input('Enter the length: ');
% Compute the N-point FFT of the input sequence
m = fft(x1, n);
% Display the DFT result in the command window
disp('N-point DFT of the given sequence:');
disp(m);
% Define frequency index vector
N = 0:1:n-1;
% Plot the magnitude spectrum of the DFT
subplot(2,2,1);
stem(N, abs(m));
xlabel('Length');
ylabel('Magnitude of X(k)');
title('Magnitude Spectrum');
% Calculate and plot the phase spectrum of the DFT
an = angle(m);
subplot(2,2,2);
stem(N, an);
xlabel('Length');
ylabel('Phase of X(k)');
title('Phase Spectrum');
Output:-
Enter the sequence:[1 1 0 0] Enter the length:4
N-point DFT of a given sequence: Columns 1 through 3
2.0000 1.0000 - 1.0000i 0
Column 4
1.0 + 1.0000i
Conclusion
The Discrete Fourier Transform (DFT) is a powerful tool for analyzing the frequency content of discrete signals,
but it is computationally intensive. The Fast Fourier Transform (FFT) efficiently computes the DFT, significantly
reducing processing time and making real-time signal analysis practical. Understanding both methods is
essential for applications in digital signal processing, communications, and image analysis.