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

Lab 2

This document outlines experiments involving algebraic operations and convolution/deconvolution of signals using MATLAB. The first experiment focuses on addition, subtraction, multiplication, and division of signals, demonstrating how these operations affect the resulting waveforms. The second experiment explores convolution and deconvolution with various signal types, emphasizing their significance in signal processing and recovery of original signals.

Uploaded by

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

Lab 2

This document outlines experiments involving algebraic operations and convolution/deconvolution of signals using MATLAB. The first experiment focuses on addition, subtraction, multiplication, and division of signals, demonstrating how these operations affect the resulting waveforms. The second experiment explores convolution and deconvolution with various signal types, emphasizing their significance in signal processing and recovery of original signals.

Uploaded by

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

Experiment No.

02
Experiment Name: Experimental study of various algebraic operations on different types of
signals like (i) addition, (ii) subtraction, (iii) multiplication and (iv) divisions of signals by
using MATLAB Software.

Objectives:
 To learn how to add, subtract, multiply and divide signals using MATLAB.
 To understand how the signal after algebraic operations will be.
Required Apparatus: MATLAB 2024b

Theory:
Addition
This operation involves combining two or more signals by adding their corresponding values
at each point in time. Mathematically, if x(t) and y(t) are two signals, their sum z(t) is given
by:
z (t)= x(t)+ y (t)
Subtraction
In signal subtraction, one signal is subtracted from another at each point in time. If x(t) and
y(t) are two signals, their difference z(t) is given by:
z (t)= x(t)– y (t)
Multiplication
Multiplying signals is often done for modulation, filtering, or other purposes. In this
operation, the values of the signals are multiplied at each point in time. If x(t) and y(t) are two
signals, their product z(t) is:
z (t)= x(t)∗y (t )
Division
Dividing signals is less common but can occur in some applications such as adaptive
filtering. In this operation, one signal is divided by another at each point in time. If x(t) and
y(t) are two signals, their quotient z(t) is:
x (t)
z (t)=
y (t )
Lab Task:

Lab Task – Algebraic Operations on Different Signals


Code:
clc;

10 | P a g e
clear all;
close all;

t = 0:0.01:5;

A = 1;
b = 0.7;
f = 2;
p = 0;

%Exponentially Damped Sinusoidal Signal


x = A * exp(-b*t).* sin(2*pi*f*t+p);
%Cosine wave
y = A * cos(2*pi*f*t+p);

%Addition
sum = x+y;
subplot(2,2,1);
plot(t,sum,'b',LineWidth=1.5);
title("Addition");
xlabel("Time");
ylabel("Amplitude");
grid on;

%Subtraction
sub = x-y;
subplot(2,2,2);
plot(t,sub,'r',LineWidth=1.5);
title("Subtraction");
xlabel("Time");
ylabel("Amplitude");
grid on;

%Multiplication
mul = x.*y;
subplot(2,2,3);
plot(t,mul,'g',LineWidth=1.5);
title("Multiplication");
xlabel("Time");
ylabel("Amplitude");
grid on;

%Division
div = x./y;
subplot(2,2,4);
plot(t,div,'black',LineWidth=1.5);
title("Division");
xlabel("Time");
ylabel("Amplitude");
grid on;

11 | P a g e
Output:

Addition Subtraction
1.5 1.5

1 1

0.5 0.5
Amplitude

Amplitude
0 0

-0.5 -0.5

-1 -1

-1.5 -1.5
0 1 2 3 4 5 0 1 2 3 4 5
Time Time

Multiplication Division
0.5 15

10

5
Amplitude

Amplitude
0 0

-5

-10

-0.5 -15
0 1 2 3 4 5 0 1 2 3 4 5
Time Time

Observation:
The MATLAB code generates and analyzes four mathematical operations on two signals:
an exponentially damped sinusoidal signal (x) and a cosine wave (y). The first operation, in
addition, produces a gradually decaying oscillation as the exponentially damped signal (x)
decays over time while the cosine wave (y) remains constant. In subtraction, the resulting
waveform represents the difference between x and y, with the decay of x becoming more
pronounced over time. Multiplication results in a waveform that oscillates with decreasing
amplitude due to the exponential decay of x, modulated by the cosine wave. Finally,
division produces a decaying oscillation, but extreme values or discontinuities may occur
when y approaches zero. Each plot demonstrates how the signals interact under these
operations, with the decay of x influencing the resulting waveforms.

Conclusion:
In conclusion, the four operations reveal how the exponentially damped signal interacts with
the cosine wave. Addition and subtraction highlight how the damping of x affects the
resulting waveform, while multiplication demonstrates how x modulates y. Division,
however, can cause discontinuities when y approaches zero. These results emphasize the
importance of understanding signal behavior in systems involving damping and oscillations.

12 | P a g e
Experiment No. 03
Experiment Name: Experimental study of convolution and deconvolution of two signals line
(i) sine wave and cosine wave, (ii) sawtooth and square wave, (iii) rectangular and square
wave by using MATLAB software.

Objectives:
1. To explore the concepts of convolution and de-convolution and their significance in
analyzing and processing signals.
2. To learn de-convolution techniques to extract the original signal from a convolved
signal, emphasizing practical applications in communication and image processing.

Required Apparatus: MATLAB 2024b

Theory:
Convolution
Convolution is a mathematical tool to combining two signals to form a third signal.
Therefore, in signals and systems, convolution is very important because it relates the input
signal and the impulse response of the system to produce the output signal from the system.
In other words, convolution is used to express the input and output relationship of an LTI
system.
Deconvolution
Deconvolution is the process of filtering a signal to compensate for an undesired convolution.
The goal of deconvolution is to recreate the signal as it existed before the convolution took
place. This usually requires the characteristics of the convolution (i.e., the impulse or
frequency response) to be known.

Lab Task:

Lab Task 1 – Convolution & Deconvolution of Sine & Cosine Wave


Code:
clc;
clear all;
close all;

t = -1:0.01:5;
a = 10;
f = 1;
p = 0;

c = a*sin(2*pi*f*t+p);
subplot(3,2,1);

13 | P a g e
plot(t,c,'r',LineWidth=1.5);
title("Sine wave");
xlabel("Time");
ylabel("Amplitude");
grid on;
axis([0 5 -11 11]);

d = a*cos(2*pi*f*t+p);
subplot(3,2,2);
plot(t,d,'b',LineWidth=1.5);
title("Cosine wave");
xlabel("Time");
ylabel("Amplitude");
grid on;
axis([0 5 -11 11]);

x = conv(c,d);
subplot(3,2,3);
plot(x, LineWidth=1.5);
title("Convulation wave");
xlabel("Time");
ylabel("Amplitude");
grid on;
axis([0 1201 -30000 30000]);

y = deconv(x,d);
subplot(3,2,4);
plot(y, LineWidth=1.5);
title("Deconvulation wave (Sine)");
xlabel("Time");
ylabel("Amplitude");
grid on;

z = deconv(x,c);
subplot(3,2,5);
plot(z, LineWidth=1.5);
title("Deconvulation wave (Cosine)");
xlabel("Time");
ylabel("Amplitude");
grid on;

14 | P a g e
Output:
Sine wave Cosine wave
10 10
Amplitude

Amplitude
0 0

-10 -10
0 1 2 3 4 5 0 1 2 3 4 5
Time Time
104 Convulation wave

2
Amplitude

-2

0 200 400 600 800 1000 1200


Time 300
Deconvulation wave (Sine) 10 Deconvulation wave (Cosine)
10 0
Amplitude

Amplitude
-2
0 -4
-6
-10
0 100 200 300 400 500 600 700 0 5 10 15 20 25
Time Time
Observation:
This MATLAB code demonstrates signal processing by generating and plotting sine and
cosine waves, performing their convolution, and applying deconvolution to approximate
the original signals. A sine wave and a cosine wave, both with an amplitude of 10,
frequency 1 Hz, and phase 0, are plotted over a time range of 0 to 5 seconds. The
convolution of these two waves produces a new signal with a larger amplitude range,
which is also plotted. Deconvolution is then applied to the convolution result: first with the
cosine wave to approximate the original sine wave and then with the sine wave to
approximate the original cosine wave. The code visualizes these operations using subplots
to help understand how convolution and deconvolution work in signal processing.

Lab Task 2 – Convolution & Deconvolution of sawtooth and square wave


Code:
clc;
clear all;
close all;

T = 1/1000;
L = 1000;
t = (0:L-1)*T;
f = 5;

x2 = sawtooth(2*pi*f*t);
subplot(3,2,1);
plot(t, x2, 'b', 'LineWidth', 1.5);
title('Original Sawtooth Wave');
15 | P a g e
xlabel('Time(s)', 'FontWeight', 'bold');
ylabel('Amplitude', 'FontWeight', 'bold');
grid on;

y2 = square(2*pi*f*t);
subplot(3,2,2);
plot(t, y2, 'r', 'LineWidth', 1.5);
title('Original Square Wave');
xlabel('Time(s)', 'FontWeight', 'bold');
ylabel('Amplitude', 'FontWeight', 'bold');
grid on;

conv_result2 = conv(x2, y2, 'full');


t_conv2 = (0:length(conv_result2)-1) * T;
subplot(3,2,[3,4]);
plot(t_conv2, conv_result2, 'm', 'LineWidth', 1.5);
title('Convolution of Sawtooth and Square Waves');
xlabel('Time(s)', 'FontWeight', 'bold');
ylabel('Amplitude', 'FontWeight', 'bold');
grid on;

[recovered_sawtooth, ~] = deconv(conv_result2, y2);


recovered_sawtooth = recovered_sawtooth(1:L);
subplot(3,2,5);
plot(t, recovered_sawtooth, 'b', 'LineWidth', 1.5);
title('Recovered Sawtooth Wave (From Deconvolution)');
xlabel('Time(s)', 'FontWeight', 'bold');
ylabel('Amplitude', 'FontWeight', 'bold');
grid on;

[recovered_square, ~] = deconv(conv_result2, x2);


recovered_square = recovered_square(1:L);
subplot(3,2,6);
plot(t, recovered_square, 'r', 'LineWidth', 1.5);
title('Recovered Square Wave (From Deconvolution)');
xlabel('Time(s)', 'FontWeight', 'bold');
ylabel('Amplitude', 'FontWeight', 'bold');
grid on;

16 | P a g e
Output:
Original Sawtooth Wave Original Square Wave
1 1
Amplitude

Amplitude
0 0

-1 -1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Time(s) Time(s)
Convolution of Sawtooth and Square Waves
500
Amplitude

-500
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time(s)
Recovered Sawtooth Wave (From Deconvolution) Recovered Square Wave (From Deconvolution)
1 1
Amplitude

Amplitude
0 0

-1 -1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Time(s) Time(s)

Observation:
This MATLAB code works with two signals: a sawtooth wave and a square wave. It
performs convolution (combining the two signals) and deconvolution (trying to separate
the original signals). In the first plot, the sawtooth wave is shown in blue. It has a
frequency of 5 Hz, meaning it repeats every 0.2 seconds. The second plot shows the square
wave in red, which also has the same frequency and alternates between 1 and -1. The third
plot shows the result of the convolution of the sawtooth and square waves. This combined
signal is longer because convolution increases the signal length. The shape of the result
reflects how the two waves interact with each other over time. The fourth plot tries to
recover the original sawtooth wave using deconvolution. The result is close to the original
wave, but there may be small errors or noise due to calculation limitations. Similarly, the
fifth plot tries to recover the square wave. It also looks like the original but may have some
distortion. In simple terms, this code demonstrates how two signals can be combined and
then separated. The recovered signals may not be perfect due to small errors in the process.

Lab Task 3 – Convolution & Deconvolution of rectangular and square wave


Code:
clc;
close all;
clear;

a = 10;
t = 0:0.001:5;
w = 2 * pi;

A = a * rectpuls(t, 1);

subplot(3, 2, 1);

17 | P a g e
plot(t, A, 'b', LineWidth = 1.2);
title('rectangle wave');
xlabel('time(t)');
ylabel('Amplitude(A)');
grid on;
axis([-10 10 -1 11]);

B = a * square(w * t);

subplot(3, 2, 2);
plot(t, B, 'r', LineWidth = 1.5);
title('square wave');
xlabel('time(t)');
ylabel('Amplitude(A)');
grid on;

D = conv(A, B);
subplot(3, 2, 3);
plot(D, 'b', LineWidth=1.5);
title('convolution');
xlabel('Samples');
ylabel('Amplitude(A)');
grid on;

C = deconv(D, B);
subplot(3, 2, 4);
plot(C, 'black', LineWidth=1.5);
title('Deconvolution of D with A (to retrieve B)');
xlabel('Samples');
ylabel('Amplitude(A)');
grid on;
axis([-3000 3000 -1 11]);

F = conv(A, B);
E = deconv(F, A);
subplot(3, 2, 5);
plot(t, E, 'm', LineWidth=1.5);
title('Deconvolution of D with B (to retrieve A)');
xlabel('Samples');
ylabel('Amplitude(A)');
grid on;

18 | P a g e
Output:

Rectangle wave Square wave


10
10
Amplitude(A)

Amplitude(A)
5 0

0
-10
-10 -5 0 5 10 0 1 2 3 4 5
Time (t) Time (t)
104 convolution
5
Amplitude(A)

-5
0 2000 4000 6000 8000 10000 12000
Time (t)
Deconvolution of D with A (to retrieve B) Deconvolution of D with B (to retrieve A)
10
10
Amplitude(A)

Amplitude(A)

5 0

0
-10
-3000 -2000 -1000 0 1000 2000 3000 0 1 2 3 4 5
Time (t) Time (t)

Observation:
The first graph shows a rectangular pulse with an amplitude of 10. The rectpuls function
creates this pulse. The axis limits are set from −10-10−10 to 101010 on the x-axis and −1-
1−1 to 111111 on the y-axis. This may crop part of the wave. The second graph shows a
square wave that alternates between +10+10+10 and −10-10−10. The frequency of the
wave is determined by 2π2\pi2π. The plot displays the wave over the time interval from
000 to 555 seconds. The third graph shows the result of convolving the rectangular pulse
(A) and the square wave (B). Convolution blends the two signals into one, creating a new
waveform that shows how the two signals interact. The fourth graph shows an attempt to
retrieve the square wave (B) by deconvolving the convolution result (D) with the
rectangular pulse (A). The output should look like the original square wave, but it might
have some small errors or noise due to numerical calculations. The fifth graph shows an
attempt to retrieve the rectangular pulse (A) by deconvolving the convolution of A and B
(F) with the square wave (B). The result should resemble the original rectangular pulse,
though it might also have some small errors.
Conclusion:
This experiment highlights the power and limitations of convolution and deconvolution in
signal processing. While convolution combines signals to reveal interactions, deconvolution
can approximate original signals but is sensitive to errors and computational constraints.
These techniques are essential in fields like communications, control systems, and audio
processing, where analyzing and recovering signals are critical tasks.

19 | P a g e

You might also like