KEMBAR78
SS LAB Manual | PDF | Sampling (Signal Processing) | Spectral Density
0% found this document useful (0 votes)
21 views45 pages

SS LAB Manual

The document outlines a Signals and Systems Lab course for Electronics and Communication Engineering students, detailing various MATLAB programming experiments. Students will learn to generate and manipulate continuous and discrete-time signals, perform arithmetic operations, and analyze signals using Fourier and Laplace transforms. The course aims to provide hands-on experience and validate theoretical concepts through practical applications.

Uploaded by

killakachantitej
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views45 pages

SS LAB Manual

The document outlines a Signals and Systems Lab course for Electronics and Communication Engineering students, detailing various MATLAB programming experiments. Students will learn to generate and manipulate continuous and discrete-time signals, perform arithmetic operations, and analyze signals using Fourier and Laplace transforms. The course aims to provide hands-on experience and validate theoretical concepts through practical applications.

Uploaded by

killakachantitej
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

KILLAKA CHANTI

23981a04z3 2nd 2nd


Signal and Systems
Electronics and Communication Engineering

2025

12
2304205-Signals & Systems Lab
Programme B. Tech - ECE Sem Category L T P Credits
& Branch
Professional
Prerequisites Nil 4 0 0 3 1.5
Core

Preamble In this Lab, the student will acquire hands-on experience with programming in
MATLAB. MATLAB programming will enable them to provide real-time
scenario to understand the theory behind signals and systems as well as validate
the theory with real-word examples.
List of Experiments:

1 Write a program to plot the following continuous time and discrete time signals.
i. Step Function
ii. Impulse Function
iii. Exponential Function
iv. Ramp Function
v. Sine Function
2 Write a program to perform arithmetic operations: addition, subtraction and multiplication
on continuous-time signals.
3 Write a program to perform amplitude-scaling, time-scaling and time shifting on a given
signal.
4 Write a program to find Energy and Power of a given signal.

5 Write a program to find the trigonometric and exponential Fourier series coefficients of a
periodic signal.
6 Write to find Fourier Transform of a given signal and plot its Magnitude and Phase
Spectrum.
7 Write a program
i) To find the Laplace Transform of a given signal.
ii) To find the inverse Laplace Transform of a given transfer function.
8 Write a program to compute and plot the impulse response and pole-zero diagram of
transfer function using Laplace transform.
9 Write a program to compute the linear convolution of continuous-time signals.

10 Write a program to compute auto correlation between two continuous-time signals.

11 Write a program to compute cross correlation between two continuous-time signals.


12 Write a program to verify the sampling theorem.
References/Manuals/Software: MATLAB / SCI Lab / Equivalent Industrial Standard Licensed
simulation software tool.
COURSE OUTCOMES: BT Mapped
On completion of the course, the student will be able to (Highest Level)
CO 1 Generate and characterize various continuous and discrete time L2
signals.
CO 2 Perform basic arithmetic operations on the signals. L3

CO 3 Analyze the spectral characteristics of signals using Fourier L4


analysis.
CO4 Analyze system characteristics using Laplace transform. L4
Compute convolution and correlation between signals and verify L5
CO5
sampling theorem.

Mapping of COs with POs and PSO:


COs/ PO- PO- PO- PO- PO- PO- PO- PO- PO- PO- PO- PO- PSO- PSO-
POs 1 2 3 4 5 6 7 8 9 10 11 12 1 2
CO 1 1 - - 2 - - - 1 - - - 3 3
3
3
CO 2 2 - - 2 - - - 1 - - - 3 3

CO 3 2 1 1 2 - - - 1 - - - 3 3
3
3
CO 4 3 1 1 2 - - - 1 - - - 3 3

CO 5 3 1 1 2 - - - 1 - - - 3 3
3
1 – Slight, 2 – Moderate, 3 – Substantial
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-01
GENERATION OF STANDARD SIGNALS

AIM: Write a program to plot the following continuous time and discrete time signals.

i. Step Function

ii. Impulse Function

iii. Exponential Function

iv. Ramp Function

v. Sine Function

APPARATUS REQUIRED:

HARDWARE: Personal Computer

SOFTWARE: MATLAB
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Signals and Systems Lab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page1
Department of Electronics & Communications Engineering SS LAB

MATLAB Program to generate continuous time signals:


clc;
clear;
close all;
% Time vector for continuous-time signals
T = -5:0.01:5;

% Step Function
u_t = (T >= 0);
figure;
plot(T, u_t, 'LineWidth', 2);
title('Continuous Step Function');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Impulse Function
impulse_t = (T == 0);
figure;
plot(T, impulse_t, 'LineWidth', 2);
title('Continuous Impulse Function (Ideal)');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Exponential Function
a = 0.5;
exp_t = exp(a*T);
figure;
plot(T, exp_t, 'LineWidth', 2);
title('Continuous Exponential Function');
xlabel('Time');
ylabel('Amplitude');
grid on;
Signals and Systems Lab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page2
Department of Electronics & Communications Engineering SS LAB

% Ramp Function
ramp_t = T .* (T >= 0);
figure;
plot(T, ramp_t, 'LineWidth', 2);
title('Continuous Ramp Function');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Sine Function
f = 1; % Frequency in Hz
sine_t = sin(2*pi*f*T);
figure;
plot(T, sine_t, 'LineWidth', 2);
title('Continuous Sine Function');
xlabel('Time');
ylabel('Amplitude');
grid on;

Signals and Systems Lab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page3
Department of Electronics & Communications Engineering SS LAB

OUTPUT :

Signals and Systems Lab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page4
Department of Electronics & Communications Engineering SS LAB

Signals and Systems Lab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page5
Department of Electronics & Communications Engineering SS LAB

MATLAB Program to generate Discrete time signals:


clc;
clear;
close all;
% Time vector for discrete-time signals
n = -5:1:5;
% Step Function
u_n = (n >= 0);
figure;
stem(n, u_n, 'filled');
title('Discrete Step Function');
xlabel('n');
ylabel('Amplitude');
grid on;
% Impulse Function
impulse_n = (n == 0);
figure;
stem(n, impulse_n, 'filled');
title('Discrete Impulse Function');
xlabel('n');
ylabel('Amplitude');
grid on;
% Exponential Function
a = 0.5;
exp_n = exp(a*n);
figure;
stem(n, exp_n, 'filled');
title('Discrete Exponential Function');
xlabel('n');
ylabel('Amplitude');
grid on;

Signals and Systems Lab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page6
Department of Electronics & Communications Engineering SS LAB

% Ramp Function
ramp_n = n .* (n >= 0);
figure;
stem(n, ramp_n, 'filled');
title('Discrete Ramp Function');
xlabel('n');
ylabel('Amplitude'); grid on;
% Sine Function
f = 1; % Frequency in Hz
sine_n = sin(0.2*pi*f*n);
figure;
stem(n, sine_n, 'filled');
title('Discrete Sine Function');
xlabel('n');
ylabel('Amplitude');
grid on;
OUTPUT :

Signals and Systems Lab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page7
Department of Electronics & Communications Engineering SS LAB

Signals and Systems Lab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page8
Department of Electronics & Communications Engineering SS LAB

RESULT:

Signals and Systems Lab, Dept of ECE, Raghu Engineering College, Visakhapatnam Page9
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT – 02
BASIC SIGNAL OPERATIONS: Addition, Subtraction and Multiplication
AIM: Write a program to perform arithmetic operations: addition, subtraction and multiplication
on continuous-time signals.

APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page10
Department of Electronics & Communications Engineering SS LAB

MATLAB program:
clc;
clear;
close all;
% Define time range
t = -5:0.01:5; % Continuous-time representation
% Define two continuous-time signals
x1 = sin(2*pi*0.5*t); % First signal (Sine wave)
x2 = cos(2*pi*0.5*t); % Second signal (Cosine wave)
% Perform Arithmetic Operations
add_signal = x1 + x2; % Addition of signals
sub_signal = x1 - x2; % Subtraction of signals
mul_signal = x1 .* x2; % Multiplication of signals (Point-wise multiplication)
% Plot Results
figure;
subplot(5,1,1);
plot(t, x1, 'b', 'LineWidth', 1.5);
title('Signal x_1(t) = sin(2\pi 0.5t)');
xlabel('Time (t)');
ylabel('Amplitude');
grid on;
subplot(5,1,2);
plot(t, x2, 'r', 'LineWidth', 1.5);
title('Signal x_2(t) = cos(2\pi 0.5t)');
xlabel('Time (t)');
ylabel('Amplitude');
grid on;
subplot(5,1,3);
plot(t, add_signal, 'g', 'LineWidth', 1.5);

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page11
Department of Electronics & Communications Engineering SS LAB

title('Addition of Signals: x_1(t) + x_2(t)');


xlabel('Time (t)');
ylabel('Amplitude');
grid on;
subplot(5,1,4);
plot(t, sub_signal, 'm', 'LineWidth', 1.5);
title('Subtraction of Signals: x_1(t) - x_2(t)');
xlabel('Time (t)');
ylabel('Amplitude');
grid on;
subplot(5,1,5);
plot(t, mul_signal, 'k', 'LineWidth', 1.5);
title('Multiplication of Signals: x_1(t) * x_2(t)');
xlabel('Time (t)');
ylabel('Amplitude');
grid on;
OUTPUT :

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page12
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT – 03

BASIC SIGNAL OPERATIONS: Amplitude-Scaling, Time-Scaling and Time Shifting

AIM: Write a program to perform amplitude-scaling, time-scaling and time shifting on a given signal.

APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page13
Department of Electronics & Communications Engineering SS LAB

MATLAB code:
clc;
clear;
close all;
% Define time range
t = -5:0.01:5; % Continuous-time approximation
% Define original signal (Example: Sinusoidal Signal)
x = sin(2*pi*0.5*t);
% Transformation parameters
A = 2; % Amplitude scaling factor
alpha = 0.5; % Time scaling factor
tau = 2; % Time shift value
% Perform Transformations
x_amplitude_scaled = A * x; % Amplitude Scaling
x_time_scaled = sin(2*pi*0.5*(alpha*t)); % Time Scaling
x_time_shifted = sin(2*pi*0.5*(t - tau)); % Time Shifting
% Plot Original and Transformed Signals
figure;
subplot(4,1,1);
plot(t, x, 'b', 'LineWidth', 1.5);
title('Original Signal: x(t) = sin(2\pi 0.5t)');
xlabel('Time (t)');
ylabel('Amplitude');
grid on;
subplot(4,1,2);
plot(t, x_amplitude_scaled, 'r', 'LineWidth', 1.5);
title('Amplitude Scaled Signal');
xlabel('Time (t)');
ylabel('Amplitude');
grid on;
subplot(4,1,3);
plot(t, x_time_scaled, 'g', 'LineWidth', 1.5);
title('Time Scaled Signal');
xlabel('Time (t)');

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page14
Department of Electronics & Communications Engineering SS LAB

ylabel('Amplitude');
grid on;
subplot(4,1,4);
plot(t, x_time_shifted, 'm', 'LineWidth', 1.5);
title('Time Shifted Signal');
xlabel('Time (t)');
ylabel('Amplitude');
grid on;

OUTPUT:

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page15
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-04
FINDING ENERGY AND POWER OF A GIVEN SIGNAL.

AIM: Write a program to find Energy and Power of a given signal.

APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page16
Department of Electronics & Communications Engineering SS LAB

MATLAB CODE:

% Energy and power of a signal


clc;
clear all;
close all;
%energy of a signal
N=input('enter the value of N');
n=-N:N;
x=cos((pi*n)/2);
E=sum(norm(x)^2);
disp('energy is');
disp(E);
%power of a signal
p=E/((2*N)+1);
disp('power is');
disp(p);
OUTPUT:
enter the value of N 4
energy is
5.0000
power is
0.5556
RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page17
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-05

TRIGONOMETRIC AND EXPONENTIAL FOURIER SERIES


AIM: Write a program to find the trigonometric and exponential Fourier series coefficients of a
periodic signal.
APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

MATLAB CODE:

clc;
clear;
close all;
% Define the period and fundamental frequency
T = 2*pi;
w0 = 2*pi/T;
% Define the periodic function (Example: x(t) = cos(t) + 0.5*sin(2*t))
x_t = @(t) cos(t) + 0.5*sin(2*t);
% Number of Fourier coefficients to compute
N = 5;
% Compute Fourier Coefficients
a0 = (1/T) * integral(@(t) x_t(t), -T/2, T/2); % DC Component
for n = 1:N
an(n) = (2/T) * integral(@(t) x_t(t).*cos(n*w0*t), -T/2, T/2);
Dept of ECE, Raghu Engineering College, Visakhapatnam
Page18
Department of Electronics & Communications Engineering SS LAB

bn(n) = (2/T) * integral(@(t) x_t(t).*sin(n*w0*t), -T/2, T/2);


end
% Display Results
fprintf('DC Component: a0 = %.4f\n', a0);
fprintf('Fourier Coefficients (an, bn):\n');
for n = 1:N
fprintf('n = %d: an = %.4f, bn = %.4f\n', n, an(n), bn(n));
end
OUTPUT:
DC Component: a0 = 0.0000
Fourier Coefficients (an, bn):
n = 1: an = 1.0000, bn = 0.0000
n = 2: an = 0.0000, bn = 0.5000
n = 3: an = -0.0000, bn = 0.0000
n = 4: an = 0.0000, bn = 0.0000
n = 5: an = -0.0000, bn = -0.0000

MATLAB Code for Exponential Fourier Series:


clc;
clear;
close all;
% Define the period and fundamental frequency
T = 2*pi;
w0 = 2*pi/T;
% Define the periodic function (Example: x(t) = cos(t) + 0.5*sin(2*t))
x_t = @(t) cos(t) + 0.5*sin(2*t);
% Number of Fourier coefficients to compute
N = 5;
% Compute Fourier Coefficients
for n = -N:N
c_n(n+N+1) = (1/T) * integral(@(t) x_t(t).*exp(-1j*n*w0*t), -T/2, T/2);
end
% Display Results
fprintf('Exponential Fourier Series Coefficients (c_n):\n');
Dept of ECE, Raghu Engineering College, Visakhapatnam
Page19
Department of Electronics & Communications Engineering SS LAB

for n = -N:N
fprintf('n = %d: c_n = %.4f + %.4fi\n', n, real(c_n(n+N+1)), imag(c_n(n+N+1)));
end
OUTPUT:
Exponential Fourier Series Coefficients (c_n):
n = -5: c_n = -0.0000 + -0.0000i
n = -4: c_n = 0.0000 + 0.0000i
n = -3: c_n = -0.0000 + -0.0000i
n = -2: c_n = 0.0000 + 0.2500i
n = -1: c_n = 0.5000 + 0.0000i
n = 0: c_n = 0.0000 + 0.0000i
n = 1: c_n = 0.5000 + -0.0000i
n = 2: c_n = 0.0000 + -0.2500i
n = 3: c_n = -0.0000 + 0.0000i
n = 4: c_n = 0.0000 + -0.0000i
n = 5: c_n = -0.0000 + 0.0000i

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page20
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-06

FOURIER TRANSFORM

AIM: Write to find Fourier Transform of a given signal and plot its Magnitude and Phase
Spectrum.
APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page21
Department of Electronics & Communications Engineering SS LAB

MATLAB CODE:

clc;
clear;
close all;
% Define the signal
t = 0:0.1:2*pi; % Time vector
x = sin(2*pi*1*t) + 0.5*sin(2*pi*2*t); % Example signal (sum of two sinusoids)
% Compute Fourier Transform
X = fft(x);
% Compute Magnitude and Phase spectra
magnitude = abs(X);
phase = angle(X);
% Compute Inverse Fourier Transform
x_reconstructed = ifft(X);
% Plot original signal
subplot(2, 2, 1);
plot(t, x);
title('Original Signal');
xlabel('Time');
ylabel('Amplitude');
% Plot Magnitude Spectrum
subplot(2, 2, 2);
stem(magnitude);
title('Magnitude Spectrum');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
% Plot Phase Spectrum
subplot(2, 2, 3);
stem(phase);
title('Phase Spectrum');
xlabel('Frequency (Hz)');
ylabel('Phase (radians)');

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page22
Department of Electronics & Communications Engineering SS LAB

OUTPUT:

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page23
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-07
LAPLACE TRANSFORM

AIM: Write a program

i) To find the Laplace Transform of a given signal.

ii) To find the inverse Laplace Transform of a given transfer function.

APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page24
Department of Electronics & Communications Engineering SS LAB

i) MATLAB CODE:

% MATLAB Program to find Laplace Transform of a given signal


clc;
clear;
close all;
% Define symbolic variables
syms t s
% Define the time-domain signal (example: exponential and step)
x = exp(-2*t) * heaviside(t); % Example signal
% Compute Laplace Transform
X = laplace(x, t, s);
% Display result
disp('Time-domain signal x(t):');
disp(x);
disp('Laplace Transform X(s):');
disp(X);

OUTPUT:

Time-domain signal x(t):


exp(-2*t)*heaviside(t)
Laplace Transform X(s):
1/(s + 2)

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page25
Department of Electronics & Communications Engineering SS LAB

ii) MATLAB CODE:


clc;
clear;
close all;
% Define symbolic variables
syms s t;
% Define the Laplace-domain function
Fs = 1/(s + 2);
% Compute the inverse Laplace Transform
ft = ilaplace(Fs, s, t);
% Display the result
disp('Inverse Laplace Transform f(t):');
pretty(ft)
% Plot the result
fplot(ft, [0, 10], 'LineWidth', 2);
grid on;
title('Inverse Laplace Transform of 1/(s + 2)');
xlabel('Time t');
ylabel('f(t)');
OUTPUT:
Inverse Laplace Transform f(t):
exp(-2 t)

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page26
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-08

POLE-ZERO DIAGRAM

AIM: Write a program to compute the impulse response and plot the pole-zero diagram of
transfer function using Laplace transform.
APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page27
Department of Electronics & Communications Engineering SS LAB

MATLAB CODE:

% Define the transfer function numerator and denominator coefficients


num = [1]; % numerator coefficients (in s)
den = [1, 2, 1]; % denominator coefficients (in s^2 + 2s + 1)
% Create the transfer function
sys = tf(num, den);
% Compute and plot impulse response
impulse_response = impulse(sys);
figure;
subplot(2,1,1);
plot(impulse_response);
title('Impulse Response');
xlabel('Time');
ylabel('Amplitude');
% Plot pole-zero diagram
subplot(2,1,2);
pzmap(sys);
title('Pole-Zero Diagram');

OUTPUT:

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page28
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-09

LINEAR CONVOLUTION

AIM: Write a program to compute the linear convolution of continuous-time signals.

APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page29
Department of Electronics & Communications Engineering SS LAB

MATLAB CODE:
clc;
clear;
close all;
% Time range and step (simulation of continuous time)
t1 = 0:0.01:5; % time for signal x(t)
t2 = 0:0.01:5; % time for signal h(t)
% Define two continuous-time signals (example signals)
x = exp(-t1); % x(t) = e^(-t)
h = sin(t2); % h(t) = sin(t)
% Compute linear convolution
y = conv(x, h) * 0.01; % Multiply by time step (dt) for continuous-time approximation
% Generate time vector for the convolved signal
t_conv = (0:(length(y)-1)) * 0.01;
% Plot the input signals and their convolution
figure;
subplot(3,1,1);
plot(t1, x, 'b', 'LineWidth', 2);
title('Signal x(t) = e^{-t}');
xlabel('Time (t)');
ylabel('x(t)');
grid on;
subplot(3,1,2);
plot(t2, h, 'r', 'LineWidth', 2);
title('Signal h(t) = sin(t)');
xlabel('Time (t)');
ylabel('h(t)');
grid on;
subplot(3,1,3);
plot(t_conv, y, 'k', 'LineWidth', 2);
title('Linear Convolution y(t) = x(t) * h(t)');
xlabel('Time (t)');
ylabel('y(t)');
grid on;

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page30
Department of Electronics & Communications Engineering SS LAB

OUTPUT:

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page31
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-10

AUTO CORRELATION

AIM: Write a program to compute auto correlation between two continuous-time signals.

APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page32
Department of Electronics & Communications Engineering SS LAB

MATLAB CODE:
% MATLAB Program to compute and plot autocorrelation of a signal
% Define time axis (discrete approximation)
t = 0:0.01:10; % Time vector from 0 to 10 with a step of 0.01 seconds
% Define the signal (e.g., sine wave)
signal = sin(2*pi*1*t); % Signal: Sine wave with frequency 1 Hz
% Compute the autocorrelation of the signal
auto_corr = xcorr(signal, 'coeff'); % Autocorrelation using xcorr
% Time axis for autocorrelation plot
t_corr = -t(end):0.01:t(end);
% Plot the original signal
figure;
subplot(2,1,1);
plot(t, signal);
title('Original Signal: Sine Wave');
xlabel('Time (s)');
ylabel('Amplitude');
% Plot the autocorrelation of the signal
subplot(2,1,2);
plot(t_corr, auto_corr);
title('Autocorrelation of Signal');
xlabel('Lag');
ylabel('Autocorrelation');
grid on;

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page33
Department of Electronics & Communications Engineering SS LAB

OUTPUT:

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page34
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-11

CROSS CORRELATION

AIM: Write a program to compute Cross correlation between two continuous-time signals.

APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page35
Department of Electronics & Communications Engineering SS LAB

MATLAB CODE:
% MATLAB Program to compute and plot cross-correlation between two signals
% Define time axis (discrete approximation)
t = 0:0.01:10; % Time vector from 0 to 10 with a step of 0.01 seconds
% Define two signals (e.g., sine and cosine waves)
signal1 = sin(2*pi*1*t); % Signal 1: Sine wave with frequency 1 Hz
signal2 = cos(2*pi*1*t); % Signal 2: Cosine wave with frequency 1 Hz
% Compute the cross-correlation between signal1 and signal2
cross_corr = xcorr(signal1, signal2, 'coeff'); % Cross-correlation
% Time axis for cross-correlation plot
t_corr = -t(end):0.01:t(end);
% Plot the signals
figure;
subplot(3,1,1);
plot(t, signal1);
title('Signal 1: Sine Wave');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, signal2);
title('Signal 2: Cosine Wave');
xlabel('Time (s)');
ylabel('Amplitude');
% Plot the cross-correlation
subplot(3,1,3);
plot(t_corr, cross_corr);
title('Cross-Correlation between Signal 1 and Signal 2');
xlabel('Lag');
ylabel('Cross-Correlation');
grid on;

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page36
Department of Electronics & Communications Engineering SS LAB

OUTPUT:

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page37
Department of Electronics & Communications Engineering SS LAB

EXPERIMENT-12

SAMPLING THEOREM

AIM: Write a program to verify the sampling theorem.

APPARATUS REQUIRED:

HARDWAR: Personal Computer


SOFTWARE: MATLAB

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page38
Department of Electronics & Communications Engineering SS LAB

MATLAB CODE:
% MATLAB Program to verify Sampling Theorem
% Define time vector for the continuous signal (high resolution)
t_cont = 0:0.001:1; % Continuous time vector from 0 to 1 second with step size 0.001 seconds
% Define frequency of the continuous-time signal
f = 10; % Frequency of the signal in Hz (less than the Nyquist frequency)
% Define the continuous signal (sine wave)
x_cont = sin(2*pi*f*t_cont);
% Sampling rates
fs1 = 20; % Sampling rate 1 (Below Nyquist rate)
fs2 = 30; % Sampling rate 2 (Above Nyquist rate)
fs3 = 50; % Sampling rate 3 (Well above Nyquist rate)
% Time vectors for sampled signals (discrete signals)
t1 = 0:1/fs1:1; % Time vector for sampling rate fs1
t2 = 0:1/fs2:1; % Time vector for sampling rate fs2
t3 = 0:1/fs3:1; % Time vector for sampling rate fs3
% Sample the continuous signal at the defined rates
x1 = sin(2*pi*f*t1); % Sampled signal at fs1
x2 = sin(2*pi*f*t2); % Sampled signal at fs2
x3 = sin(2*pi*f*t3); % Sampled signal at fs3
% Reconstruct the sampled signals using interpolation (zero-order hold)
x1_reconstructed = sin(2*pi*f*t_cont); % Reconstructed signal for fs1 (same frequency, no aliasing)
x2_reconstructed = sin(2*pi*f*t_cont); % Reconstructed signal for fs2 (same frequency, no aliasing)
x3_reconstructed = sin(2*pi*f*t_cont); % Reconstructed signal for fs3 (same frequency, no aliasing)
% Plot the results
figure;
% Plot continuous-time signal
subplot(4,1,1);
plot(t_cont, x_cont, 'LineWidth', 1.5);
title('Original Continuous-Time Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Plot sampled signal at fs1 (Below Nyquist rate)
subplot(4,1,2);
stem(t1, x1, 'r', 'LineWidth', 1.5);
Dept of ECE, Raghu Engineering College, Visakhapatnam
Page39
Department of Electronics & Communications Engineering SS LAB

hold on;
plot(t_cont, x_cont, 'b', 'LineWidth', 1); % Plot continuous signal for comparison
title(['Sampled Signal at fs1 = ' num2str(fs1) ' Hz (Below Nyquist)']);
xlabel('Time (s)');
ylabel('Amplitude');
legend('Sampled Signal', 'Continuous Signal');
% Plot sampled signal at fs2 (Above Nyquist rate)
subplot(4,1,3);
stem(t2, x2, 'g', 'LineWidth', 1.5);
hold on;
plot(t_cont, x_cont, 'b', 'LineWidth', 1); % Plot continuous signal for comparison
title(['Sampled Signal at fs2 = ' num2str(fs2) ' Hz (Above Nyquist)']);
xlabel('Time (s)');
ylabel('Amplitude');
legend('Sampled Signal', 'Continuous Signal');
% Plot sampled signal at fs3 (Well above Nyquist rate)
subplot(4,1,4);
stem(t3, x3, 'm', 'LineWidth', 1.5);
hold on;
plot(t_cont, x_cont, 'b', 'LineWidth', 1); % Plot continuous signal for comparison
title(['Sampled Signal at fs3 = ' num2str(fs3) ' Hz (Well Above Nyquist)']);
xlabel('Time (s)');
ylabel('Amplitude');
legend('Sampled Signal', 'Continuous Signal');

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page40
Department of Electronics & Communications Engineering SS LAB

OUTPUT:

RESULT:

Dept of ECE, Raghu Engineering College, Visakhapatnam


Page41

You might also like