0% found this document useful (0 votes)
9 views93 pages

BS - Record - 2

The document outlines two experiments involving basic operations on matrices and the generation of various signals using MATLAB. It details the necessary software, theoretical background, procedures, and example programs for performing matrix operations and generating signals like sine, cosine, and unit step signals. The results of the operations and signal generation are also provided, demonstrating the outcomes of the MATLAB code.

Uploaded by

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

BS - Record - 2

The document outlines two experiments involving basic operations on matrices and the generation of various signals using MATLAB. It details the necessary software, theoretical background, procedures, and example programs for performing matrix operations and generating signals like sine, cosine, and unit step signals. The results of the operations and signal generation are also provided, demonstrating the outcomes of the MATLAB code.

Uploaded by

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

BS LAB [Type here] 23011A0420

Experiment No.:1

BASIC OPERATIONS ON MATRICES

AIM: To perform basic operations on matrices.


SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
Definition: A matrix is defined as an ordered rectangular array of numbers.
They can be used to represent systems of linear equations.

MATLAB treats all variables as matrices. Vectors are special forms of matrices
and contain only one row or one column. Whereas scalars are special forms of
Matrices and contain only one row and one column. A Matrix with one row is
called row vector and a Matrix with single column is called column vector. Some
of convenient matrix building functions are as follows:

 A+B: Performs Addition of Matrices.


 A-B: Performs Subtraction of Matrices.
 A*B: Performs Multiplication of Matrices.
 A/B: Performs Division of Matrices.
 A*B: Performs Element Wise Multiplication of Matrices.
 A./B:Performs Element Wise Division of Matrices.
 cat(x,A,B):Performs Concatination of Matrices(x is the Dimension of
Matrices).
 Selection: Selects a sub matrix or row or column of a matrix.
 Deletion: Deletes a sub matrix or row or column of a matrix.
1
BS LAB [Type here] 23011A0420

 length(A): Gives length of a Matrix.


 size(A): Gives size of a Matrix.
 rank(A):Gives rank of a Matrix.
 det(A):Gives Determinant of a Matrix.
 eig(A):Gives Eigen values of a Matrix.
 trace(A):Gives trace of a Matrix.
 diag(A):Gives diagonal elements of a Matrix.
 inv(A): Gives Inverse of a Matrix.
 transpose(A):Gives transpose of a Matrix.

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM:
clc;clear all;close all;

A=[1,2,3;4,5,6;7,8,9];
B=[3,2,1;6,5,4;9,8,7];

m_add=A+B
m_mul=A*B
m_mulE=A.*B
m_rank=rank(A)
m_det=det(A)
m_len=length(A)
m_diag=diag(A)
m_trans=transpose(A)
2
BS LAB [Type here] 23011A0420

m_cat1=cat(1,A,B)
m_cat2=cat(2,A,B)
m_sel_r=A(2,:)
m_sel_r=A(:,2)
m_sel_all=A(:,:)
m_sel_p=A(1:2,2:3)

RESULT:

m_add =

4 4 4
10 10 10
16 16 16

m_mul =

42 36 30
96 81 66
150 126 102

m_mulE =

3 4 3
24 25 24
63 64 63

m_rank =

m_det =

3
BS LAB [Type here] 23011A0420

6.6613e-16

m_len =

m_diag =

1
5
9

m_trans =

1 4 7
2 5 8
3 6 9

m_cat1 =

1 2 3
4 5 6
7 8 9
3 2 1
6 5 4
9 8 7

m_cat2 =

1 2 3 3 2 1
4 5 6 6 5 4
7 8 9 9 8 7

4
BS LAB [Type here] 23011A0420

m_sel_r =

4 5 6

m_sel_r =

2
5
8

m_sel_all =

1 2 3
4 5 6
7 8 9

m_sel_p =

2 3
5 6

RESULT:
Hence, basic operation of signals are performed.

Experiment No.:2

5
BS LAB [Type here] 23011A0420

GENERATION OF VARIOUS SIGNALS AND


SEQUENCES

AIM: To generate various signals and sequences.


SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
Functions that are frequently used or that can take more time to
execute are often implemented as executable files. These functions are
called built-ins. AB program file functions, you cannot see the source code
for built-ins. Although most built-in functions do have a program file
associated with them, this file is there mainly to supply the help
documentation for the function.

If the amplitude of the signal is defined at every instant of time


then it is called continuous time signal. If the amplitude of the signal is
defined at only at some instants of time then it is called discrete time
signal. If the signal repeats itself at regular intervals then it is called
periodic signal. Otherwise they are called aperiodic signals.
EX: ramp,Impulse,unit step, sinc- Aperiodic signals
square,sawtooth,triangular sinusoidal – periodic signals.

1. Delta or unit impulse function:


One of the more useful functions in the study of linear systems is the
"unit impulse function."An ideal impulse function is a function that is zero
everywhere but at
the origin, where it is infinitely high. However, the
area of the impulse is finite.

Y(t)= 1 when t=0


= 0 other wise

A discrete time unit ramp signal is denoted by ur(n). its


6
BS LAB [Type here] 23011A0420

value increases linearly with sample number n.


mathematically it is defined as,

r(n)= n for n = 0

= 0 for n < 0

2. Unit step signal:

Unit step signal means the signal has unit amplitude for
positive axis and has zero amplitude for negative axis.

There are two types of unit step signal as follows:


1) Discrete time unit step signal: A discrete time
unit step signal is denoted by u(n), its value is one
for n = 0. While for other values of n, its value is
zero.
u(n)= 1 for n =0,
= 0 for n < 0

2) Continuous time unit step signal: A


continuous type unit step signal is denoted
by u(t). mathematically it can be expressed
as,
u(t)= 1 for t =0
= 0 for t <0

3. Unit ramp signal:

A discrete time unit ramp signal is denoted by ur(n). its


value increases linearly with sample number n.
mathematically it is defined as,

r(n)= n for n =0

= 0 for n <0

A continuous time ramp type signal is denoted by r(t).

7
BS LAB [Type here] 23011A0420

mathematically it is expressed as, r(t) = 1 for t =1

4. Exponential signal:

A discrete time exponential signal is expressed as, 𝑥(𝑛) =𝑎𝑛

For a>1 For a<-1

5. Sinusoidal waveform:

A sinusoidal signal has the same shape as the graph of the sine function used
in trigonometry. Sinusoidal signals are produced by rotating electrical
machines such as dynamos and power station turbines and electrical energy
is transmitted to the consumer in this form. There are two types of sinusoidal
waveforms:

A discrete time sinusoidal waveform is denoted by, x(n) = A sin (wn)


Continuous time sinusoidal signals: x(t) = A sin (wt) = A sin (2pft)

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.

8
BS LAB [Type here] 23011A0420

 Observe the text outputs in command window and graphical outputs in


FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM_1:
%Generation of various signals
clc; clear all; close all;

%Generation of sine signal


f=0.01;
t=0:1:100;
y1=sin(2*pi*f*t);
subplot(3,3,1);
plot(t,y1); grid on;
title("sine signal"); xlabel("time"); ylabel("amplitude");

%Generation of cosine signal


f=0.01;
t=0:1:100;
y2=cos(2*pi*f*t);
subplot(3,3,2);
plot(t,y2); grid on;
title("cosine signal"); xlabel("time"); ylabel("amplitude");

%Generation of sawtooth signal


f=0.01;
t=0:0.001:50;
y3=sawtooth(t);
subplot(3,3,3);
plot(t,y3); grid on;
title("sawtooth signal"); xlabel("time"); ylabel("amplitude");

%Generation of square signal


f=0.01;
t=0:0.001:50;
y4=square(t);
subplot(3,3,4);
9
BS LAB [Type here] 23011A0420

plot(t,y4); grid on;


title("square signal"); xlabel("time"); ylabel("amplitude");

%Generation of unit step signal


t=-100:0.1:100;
length(t);
y1=[zeros(1,1000),ones(1,1001)];
subplot(3,3,5);
plot(t,y1); grid on;
title("unit step signal"); xlabel("time"); ylabel("amplitude");

%Generation of unit impulse signal


t=-10:0.01:10;
y2=[zeros(1,1000),ones(1,1),zeros(1,1000)];
subplot(3,3,6);
plot(t,y2); grid on;
title("unit impulse signal"); xlabel("time"); ylabel("amplitude");

%Generation of ramp signal


t=0:0.01:10;
y3=t;
subplot(3,3,7);
plot(t,y3); grid on;
title("ramp signal"); xlabel("time"); ylabel("amplitude");

%Generation of exponential signal


t=-10:0.1:10;
y4=exp(2*t);
subplot(3,3,8);
plot(t,y4); axis([-10,10,0,6]); grid on;
title("exponential signal"); xlabel("time"); ylabel("amplitude");

%Generation of sinc signal


f=0.01
t=-5:0.01:5;
y5=sinc(t);
subplot(3,3,9);
plot(t,y5); grid on;
10
BS LAB [Type here] 23011A0420

title("sinc signal"); xlabel("time"); ylabel("amplitude");

OUTPUT:

PROGRAM_2:
%Generation of various signals using loops
clc; clear all; close all;

%Generation of unit step signal


t=-10:0.01:10;
for i=1:1:length(t)
if(t(i)>0)
y1(i)=1;
else
y1(i)=0
end
end
subplot(3,3,1);
plot(t,y1); axis([-12,12,-2,2]); grid on;
title("unit step signal"); xlabel("time"); ylabel("amplitude");

%Generation of unit impulse signal


t=-10:0.01:10;
for i=1:1:length(t)
if(t(i)==0)
11
BS LAB [Type here] 23011A0420

y2(i)=1;
else
y2(i)=0
end
end
subplot(3,3,2);
plot(t,y2); axis([-12,12,-2,2]); grid on;
title("unit impulse signal"); xlabel("time"); ylabel("amplitude");

%Generation of square signal


t=0:0.01:10;
for i=1:1:length(t)
if(t(i)<4)
y3(i)=0;
elseif(t(i)<6)
y3(i)=1;
elseif(t(i)<8)
y3(i)=0;
else
y3(i)=1;
end
end
subplot(3,3,3);
plot(t,y3); axis([4,10,0,1]); grid on;
title("square signal"); xlabel("time"); ylabel("amplitude");

%Generation of triangular signal


t=0:1:8;
for i=1:1:length(t)
if(t(i)<2)
y4(i)=t(i);
elseif(t(i)<6)
y4(i)=-t(i)+4;
else
y4(i)=t(i)-8;
end
end
subplot(3,3,4);
12
BS LAB [Type here] 23011A0420

plot(t,y4); grid on;


title("triangular signal"); xlabel("time"); ylabel("amplitude");

%Generation of ramp signal


t=0:0.01:10;
for i=1:1:length(t)
y5(i)=t(i)
end
subplot(3,3,5);
plot(t,y5); grid on;
title("ramp signal"); xlabel("time"); ylabel("amplitude");

%Generation of exponential signal


t=-10:0.001:10;
for i=1:1:length(t)
y6(i)=exp(2*t(i))
end
subplot(3,3,6);
plot(t,y6); axis([-20,20,0,6]); grid on;
title("exponential signal"); xlabel("time"); ylabel("amplitude");

%Generation of parabolic signal


t=-10:0.01:10;
for i=1:1:length(t)
y7(i)=t(i)^2
end
subplot(3,3,7);
plot(t,y7); grid on;
title("parabolic signal"); xlabel("time"); ylabel("amplitude");

%Generation of sinc signal


t=-10:0.01:10;
for i=1:1:length(t)
y8(i)=(sin(pi*t(i)))/(pi*t(i))
end
subplot(3,3,8);
plot(t,y8); grid on;
title("sinc signal"); xlabel("time"); ylabel("amplitude");
13
BS LAB [Type here] 23011A0420

OUTPUT:

PROGRAM_3:
%Generation of various signals using time basis
clc; clear all; close all;

%Generation of unit step signal


t=-10:0.01:10;
y1=0.*(t<0)+1.*(t>0)
subplot(3,3,1);
plot(t,y1); axis([-12,12,-2,2]); grid on;
title("unit step signal"); xlabel("time"); ylabel("amplitude");

%Generation of unit impulse signal


t=-10:0.01:10;
y2=0.*(t<0)+1.*(t==0)+0.*(t>0)
subplot(3,3,2);
plot(t,y2); axis([-12,12,-2,2]); grid on;
title("unit impulse signal"); xlabel("time"); ylabel("amplitude");

%Generation of square signal


t=0:0.01:6;
y3=0.*(t>=0&t<2)+1.*(t>=2&t<4)
14
BS LAB [Type here] 23011A0420

subplot(3,3,3);
plot(t,y3);grid on;
title("square signal"); xlabel("time"); ylabel("amplitude");

%Generation of triangular signal


t=0:1:8;
y4=t.*(t>=0&t<2)+(-t+4).*(t>=2&t<6)+(t-8).*(t>=6&t<8)
subplot(3,3,4);
plot(t,y4); axis([-12,12,-2,2]); grid on;
title("triangular signal"); xlabel("time"); ylabel("amplitude");

%Generation of ramp signal


t=0.01:10;
y5= t.*(t>=-10&t<=10)
subplot(3,3,5);
plot(t,y5); grid on;
title("ramp signal"); xlabel("time"); ylabel("amplitude");

%Generation of exponential signal


t=-20:0.1:20;
y6=exp(t).*(t>=-20&t<=20)
subplot(3,3,6);
plot(t,y6); axis([-20,20,0,6]); grid on;
title("exponential signal"); xlabel("time"); ylabel("amplitude");

%Generation of parabolic signal


t=-10:0.01:10;
y7=t.^2.*(t>=-10&t<=10)
subplot(3,3,7);
plot(t,y7); grid on;
title("parabolic signal"); xlabel("time"); ylabel("amplitude");

%Generation of sinc signal


t=-10:0.01:10;
y8=(sin(pi*t)./(pi*t)).*(t>=-10&t<=10)
subplot(3,3,8);
plot(t,y8); grid on;
title("sinc signal"); xlabel("time"); ylabel("amplitude");
15
BS LAB [Type here] 23011A0420

OUTPUT:

PROGRAM_4:
%Generation of various sequences
clc; clear all; close all;

%Generation of sine sequence


f=0.01;
n=0:10:100;
y1=sin(2*pi*f*n);
subplot(5,2,1);
stem(n,y1);
title("sine signal");
xlabel("n"); ylabel("amplitude");
grid on;

%Generation of cosine sequence


f=0.01;
n=0:10:100;
y2=cos(2*pi*f*n);
subplot(5,2,2);
stem(n,y2); grid on;
title("cosine sequence"); xlabel("n"); ylabel("amplitude");

16
BS LAB [Type here] 23011A0420

%Generation of unit step sequence


n=-10:1:10;
y3=0.*(n<0)+1.*(n>0)
subplot(5,2,3);
stem(n,y3); axis([-12,12,-2,2]); grid on;
title("unit step sequence"); xlabel("n"); ylabel("amplitude");

%Generation of unit impulse sequence


n=-10:1:10;
y4=0.*(n<0)+1.*(n==0)+0.*(n>0)
subplot(5,2,4);
stem(n,y4); axis([-12,12,-2,2]); grid on;
title("unit impulse sequence"); xlabel("n"); ylabel("amplitude");

%Generation of square sequence


n=0:1:6;
y5=0.*(n>=0&n<2)+1.*(n>=2&n<4)
subplot(5,2,5);
stem(n,y5);grid on;
title("square sequence"); xlabel("n"); ylabel("amplitude");

%Generation of triangular sequence


n=0:1:8;
y6=n.*(n>=0&n<2)+(-n+4).*(n>=2&n<6)+(n-8).*(n>=6&n<8)
subplot(5,2,6);
stem(n,y6); axis([-12,12,-2,2]); grid on;
title("triangular sequence"); xlabel("n"); ylabel("amplitude");

%Generation of ramp sequence


n=0:1:10;
y7= n.*(n>=-10&n<=10)
subplot(5,2,7);
stem(n,y7); grid on;
title("ramp sequence"); xlabel("n"); ylabel("amplitude");

%Generation of exponential signal


n=-20:1:20;
y8=exp(n).*(n>=-20&n<=20)
17
BS LAB [Type here] 23011A0420

subplot(5,2,8);
stem(n,y8); axis([-20,20,0,10]); grid on;
title("exponential sequence"); xlabel("n"); ylabel("amplitude");

%Generation of parabolic sequence


n=-10:1:10;
y9=n.^2.*(n>=-10&n<=10)
subplot(5,2,9);
stem(n,y9); grid on;
title("parabolic sequence"); xlabel("n"); ylabel("amplitude");

%Generation of sinc sequence


n=-10:1:10;
y10=(sin(pi*n)./(pi*n)).*(n>=-10&n<=10)
subplot(5,2,10);
stem(n,y10); grid on;
title("sinc sequence"); xlabel("n"); ylabel("amplitude");

OUTPUT:

18
BS LAB [Type here] 23011A0420

RESULT:
Hence, the different types of signal and sequences are performed and
generated using MATLAB.

Experiment No.:3

OPERATIONS ON SIGNALS SIGNALS AND


SEQUENCES

AIM: To perform various operations on signals and sequences.


SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
A signal, comprises of a set of information expressed as a function of any
number of independent variables, that can be given as an input to a
system, or derived as output from the system, to realize its true practical

19
BS LAB [Type here] 23011A0420

utility. The signal we derive out of a complex system might not always be

∴ being well acquainted with some basic signal operations may come really
in the form we want,

handy to enhance the understandability and applicability of signals.


Signal

Operations

Addition

Subtraction

Multiplication

division

Time Scaling:
If a constant is multiplied to the time axis then it is known as Time scaling.
So the y-axis being same, the x- axis magnitude decreases or increases
according to the sign of the constant (whether positive or negative).
Therefore, scaling can also be divided into two categories as discussed
below.

Time Compression
Whenever alpha is greater than zero, the signal’s amplitude gets divided by
alpha whereas the value of the Y-axis remains the same. This is known as
Time Compression.

Time Expansion
When the time is divided by the constant alpha, the Y-axis magnitude of the
signal get multiplied alpha times, keeping X-axis magnitude as it is. Therefore,
this is called Time expansion type signal.

Amplitude Scaling
Multiplication of a constant with the amplitude of the signal causes
amplitude scaling. Depending upon the sign of the constant, it may be
either amplitude scaling or attenuation
20
BS LAB [Type here] 23011A0420

Amplitude Compression
If the multiplied constant is less then 1 then it results in amplitude
compression

Amplitude Expansion
If the multiplied constant is greater then 1 then it results in amplitude
expansion

Time Shifting:
Suppose that we have a signal x(t) and we define a new signal by
adding/subtracting a finite time value to/from it. We now have a new
signal, y(t). The mathematical expression for this would be x(t+t0).
Graphically, this kind of signal operation results in a positive or negative
“shift” of the signal along its time axis. However, note that while doing so,
none of its characteristics are altered. This means that the time-shifting
operation results in the change of just the positioning of the signal without
affecting its amplitude or span.

Case 1 (t0 > 0):


When K is greater than zero, the shifting of the signal takes place towards
"left" in the time domain. Therefore, this type of shifting is known as Left
Shifting of the signal.
Case 2 (t0 < 0):
When K is less than zero the shifting of signal takes place towards right in
the time domain. Therefore, this type of shifting is known as Right shifting.

Amplitude Shifting:
Suppose that we have a signal x(t) and we define a new signal by
adding/subtracting a finite time value to/from it. We now have a new
signal, y(t). The mathematical expression for this would be x(t)+K.
Graphically, this kind of signal operation results in a positive or negative
“shift” of the signal along its amplitude axis. However, note that while
doing so, none of its characteristics are altered. This means that the
amplitude-shifting operation results in the change of just the amplitude of
the signal without affecting its position.

21
BS LAB [Type here] 23011A0420

Case 1 (K > 0):


When K is greater than zero, the shifting of signal takes place towards up
in the x-axis. Therefore, this type of shifting is known as upward shifting.
Case 2 (K < 0):
When K is less than zero shifting of signal takes place towards downward in
the X- axis. Therefore, it is called downward shifting of the signal.

Folding of Signals:
Folding along y-axis:
Suppose that we have a signal x(t) and we define a new signal by
adding/subtracting a finite time value to/from it. We now have a new
signal, y(t). The mathematical expression for this would be k*x(t) (k=-1)
Folding along x-axis:
Suppose that we have a signal x(t) and we define a new signal by
adding/subtracting a finite time value to/from it. We now have a new
signal, y(t). The mathematical expression for this would be x(k*t)(k=-1)

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM_1:
%To perform basic arithmetic operations on signals
clc; clear all; close all;

%Generation of y1 signal
t = 0:0.01:8;

22
BS LAB [Type here] 23011A0420

y1 =(2.*t).*(t>=0&t<2)+4.*(t>=2&t<6)+(-2.*t+16).*(t>=6&t<=8)
subplot(3,2,1);
plot(t,y1); axis([0,8,-2,8]); grid on;
title("y1 signal"); xlabel("time"); ylabel("amplitude");

%Generation of y2 signal
t = 0:0.01:8;
y2 = 2.*(t>=0&t<3)+1.*(t>=3&t<5)+2.*(t>=5&t<8)
subplot(3,2,2);
plot(t,y2); axis([0,8,-2,8]); grid on;
title("y2 signal"); xlabel("time"); ylabel("amplitude");

%Generation of y1+y2 signal


y3=y1+y2
subplot(3,2,3);
plot(t,y3); axis([0,8,-2,8]); grid on;
title("y=y1+y2 signal"); xlabel("time"); ylabel("amplitude");

%Generatio3n of y1-y2 signal


y4=y1-y2
subplot(3,2,4);
plot(t,y4); axis([0,8,-2,8]); grid on;
title("y=y1-y2 signal"); xlabel("time"); ylabel("amplitude");

%Generatio3n of y1*y2 signal


y5=y1.*y2
subplot(3,2,5);
plot(t,y5); axis([0,8,-2,8]); grid on;
title("y=y1*y2 signal"); xlabel("time"); ylabel("amplitude");

%Generatio3n of y1*y2 signal


y5=y1.*y2
subplot(3,2,5);
plot(t,y5); axis([0,8,-2,8]); grid on;
title("y=y1*y2 signal"); xlabel("time"); ylabel("amplitude");

%Generatio3n of y1/y2 signal


y6=y1./y2
23
BS LAB [Type here] 23011A0420

subplot(3,2,6);
plot(t,y6); axis([0,8,-2,8]); grid on;
title("y=y1/y2 signal"); xlabel("time"); ylabel("amplitude");

OUTPUT:

PROGRAM_2:
%To perform scaling operations on signals
clc; clear all; close all;

%Generation of y signal
t=0:0.01:12
y=2.*(t>=0&t<2)+t.*(t>=2&t<4)+2.*(t>=4&t<=6)
subplot(3,2,1);
plot(t,y); axis([0,12,0,8]); grid on;
title("y signal"); xlabel("time"); ylabel("amplitude");

%Generation of amplification signal of y


24
BS LAB [Type here] 23011A0420

y1=y.*2
subplot(3,2,3);
plot(t,y1); axis([0,12,0,8]); grid on;
title("amplification signal of y"); xlabel("time"); ylabel("amplitude");

%Generation of attenuation signal of y


y2=y./2
subplot(3,2,4);
plot(t,y2); axis([0,12,0,8]); grid on;
title("attenuation signal of y"); xlabel("time"); ylabel("amplitude");

%Generation of compressed signal of y


y3=2.*(t>=0&t<1)+(2.*t).*(t>=1&t<2)+2.*(t>=2&t<=3)
subplot(3,2,5);
plot(t,y3); axis([0,12,0,8]); grid on;
title("compressed signal of y"); xlabel("time"); ylabel("amplitude");

%Generation of expanded signal of y


y4=2.*(t>=0&t<4)+(t./2).*(t>=4&t<8)+2.*(t>=8&t<=12)
subplot(3,2,6);
plot(t,y4); axis([0,12,0,8]); grid on;
title("expanded signal of y"); xlabel("time"); ylabel("amplitude");

OUTPUT:

25
BS LAB [Type here] 23011A0420

PROGRAM_3:
%To perform shifting operations on signals
clc; clear all; close all;

%Generation of y signal
t=-2:0.01:12
y=2.*(t>=0&t<2)+t.*(t>=2&t<4)+2.*(t>=4&t<=6)
subplot(3,2,1);
plot(t,y); axis([-2,8,-2,6]); grid on;
title("y signal"); xlabel("time"); ylabel("amplitude");

%Generation of reversal signal of y


y1=fliplr(y)
subplot(3,2,2);
plot(t,y1); axis([-2,12,-2,6]); grid on;
title("reversal signal"); xlabel("time"); ylabel("amplitude");

%Generation of amplitude shifting upwards signal


y2=y+2
subplot(3,2,3);
plot(t,y2); axis([-2,8,-2,6]); grid on;
title("amplitude shifting upwards signal"); xlabel("time"); ylabel("amplitude");

%Generation of amplitude shifting downwards signal


y3=y-2
subplot(3,2,4);
plot(t,y3); axis([-2,8,-2,6]); grid on;
title("amplitude shifting upwards signal"); xlabel("time"); ylabel("amplitude");

%Generation of time delay signal


y4=y
subplot(3,2,5);
plot(t-2,y4); axis([-2,8,-2,6]); grid on;
title("time delay signal"); xlabel("time"); ylabel("amplitude");

%Generation of time advanced signal


y5=y
subplot(3,2,6);
26
BS LAB [Type here] 23011A0420

plot(t+2,y5); axis([-2,8,-2,6]); grid on;


title("time advanced signal"); xlabel("time"); ylabel("amplitude");

OUTPUT:

PROGRAM_4:
%Compute energy and average power signals
clc; clear all; close all;

%Generation of parabolic signal


t=-10:0.01:10;
y=t.^2.*(t>=-10&t<=10)
plot(t,y); grid on;
title("parabolic signal"); xlabel("time"); ylabel("amplitude");

% Energy signal of y
energy=sum(abs(y).^2);
disp(['energy of y signal:',num2str(energy)])

%Average power signal of y


avg_power=mean(abs(y).^2);
disp(['average power of y signal:',num2str(avg_power)])
27
BS LAB [Type here] 23011A0420

OUTPUT:

energy of y signal:4010006.6667
average power of y signal:2004.0013

PROGRAM_5:
%To perform basic arithmetic operations on sequences
clc; clear all; close all;

%Generation of y1 sequence
n= 0:1:8;
y1 =(2.*n).*(n>=0&n<2)+4.*(n>=2&n<6)+(-2.*n+16).*(n>=6&n<=8)
subplot(3,2,1);
stem(n,y1); axis([0,8,-2,8]); grid on;
title("y1 sequence"); xlabel("n"); ylabel("amplitude");

%Generation of y2 sequence
n=0:1:8;
y2 = 2.*(n>=0&n<3)+1.*(n>=3&n<5)+2.*(n>=5&n<8)
28
BS LAB [Type here] 23011A0420

subplot(3,2,2);
stem(n,y2); axis([0,8,-2,8]); grid on;
title("y2 sequence"); xlabel("n"); ylabel("amplitude");

%Generation of y1+y2 sequence


y3=y1+y2
subplot(3,2,3);
stem(n,y3); axis([0,8,-2,8]); grid on;
title("y=y1+y2 sequence"); xlabel("n"); ylabel("amplitude");

%Generatio3n of y1-y2 sequence


y4=y1-y2
subplot(3,2,4);
stem(n,y4); axis([0,8,-2,8]); grid on;
title("y=y1-y2 sequence"); xlabel("n"); ylabel("amplitude");

%Generation of y1*y2 signal


y5=y1.*y2
subplot(3,2,5);
stem(n,y5); axis([0,8,-2,8]); grid on;
title("y=y1*y2 sequence"); xlabel("n"); ylabel("amplitude");

%Generation of y1*y2 sequence


y5=y1.*y2
subplot(3,2,5);
stem(n,y5); axis([0,8,-2,8]); grid on;
title("y=y1*y2 sequence"); xlabel("n"); ylabel("amplitude");

%Generation of y1/y2 sequence


y6=y1./y2
subplot(3,2,6);
stem(n,y6); axis([0,8,-2,8]); grid on;
title("y=y1/y2 sequence"); xlabel("n"); ylabel("amplitude");

OUTPUT:
29
BS LAB [Type here] 23011A0420

PROGRAM_6:
%To perform scaling operations on sequence
clc; clear all; close all;

%Generation of y sequence
n=0:1:12
y=2.*(n>=0&n<2)+n.*(n>=2&n<4)+2.*(n>=4&n<=6)
subplot(3,2,1);
stem(n,y); axis([0,12,0,8]); grid on;
title("y sequence"); xlabel("n"); ylabel("amplitude");

%Generation of amplification sequence of y


y1=y.*2
subplot(3,2,3);
stem(n,y1); axis([0,12,0,8]); grid on;
title("amplification sequence of y"); xlabel("n"); ylabel("amplitude");

%Generation of attenuation sequence of y


y2=y./2
subplot(3,2,4);
stem(n,y2); axis([0,12,0,8]); grid on;
30
BS LAB [Type here] 23011A0420

title("attenuation sequence of y"); xlabel("n"); ylabel("amplitude");

%Generation of compressed sequence of y


y3=2.*(n>=0&n<1)+(2.*n).*(n>=1&n<2)+2.*(n>=2&n<=3)
subplot(3,2,5);
stem(n,y3); axis([0,12,0,8]); grid on;
title("compressed sequence of y"); xlabel("n"); ylabel("amplitude");

%Generation of expanded sequence of y


y4=2.*(n>=0&n<4)+(n./2).*(n>=4&n<8)+2.*(n>=8&n<=12)
subplot(3,2,6);
stem(n,y4); axis([0,12,0,8]); grid on;
title("compressed sequence of y"); xlabel("n"); ylabel("amplitude");

OUTPUT:

PROGRAM_7:
%To perform shifting operations on sequences
clc; clear all; close all;

%Generation of y sequences
n=-2:0.5:12
y=2.*(n>=0&n<2)+n.*(n>=2&n<4)+2.*(n>=4&n<=6)
31
BS LAB [Type here] 23011A0420

subplot(3,2,1);
stem(n,y); axis([-2,8,-2,6]); grid on;
title("y sequence"); xlabel("n"); ylabel("amplitude");

%Generation of reversal sequences of y


y1=fliplr(y)
subplot(3,2,2);
stem(n,y1); axis([-2,12,-2,6]); grid on;
title("reversal sequences"); xlabel("n"); ylabel("amplitude");

%Generation of amplitude shifting upwards sequences


y2=y+2
subplot(3,2,3);
stem(n,y2); axis([-2,8,-2,6]); grid on;
title("amplitude shifting upwards sequences"); xlabel("n"); ylabel("amplitude");

%Generation of amplitude shifting downwards sequences


y3=y-2
subplot(3,2,4);
stem(n,y3); axis([-2,8,-2,6]); grid on;
title("amplitude shifting upwards sequences"); xlabel("n"); ylabel("amplitude");

%Generation of time delay sequences


y4=y
subplot(3,2,5);
stem(n-2,y4); axis([-2,8,-2,6]); grid on;
title("time delay sequences"); xlabel("n"); ylabel("amplitude");

%Generation of time advanced sequences


y5=y
subplot(3,2,6);
stem(n+2,y5); axis([-2,8,-2,6]); grid on;
title("time advanced signal"); xlabel("n"); ylabel("amplitude");

OUTPUT:
32
BS LAB [Type here] 23011A0420

PROGRAM_8:
%Compute energy and average power sequences
clc; clear all; close all;

%Generation of parabolic sequence


n=-10:1:10;
y=n.^2.*(n>=-10&n<=10)
stem(n,y); grid on;
title("parabolic sequence"); xlabel("n"); ylabel("amplitude");

% Energy sequence of y
energy=sum(abs(y).^2);
disp(['energy of y sequence:',num2str(energy)])

%Average power sequence of y


avg_power=mean(abs(y).^2);
disp(['average power of y sequence:',num2str(avg_power)])

OUTPUT:

33
BS LAB [Type here] 23011A0420

energy of y sequence:50666
average power of y sequence:2412.6667

RESULT:
Hence, basic operations, scaling, shifting, folding operations and computation
of energy and average power signals and sequences are performed and
generated in MATLAB.

34
BS LAB [Type here] 23011A0420

Experiment No.:4

FINDING EVEN AND ODD PARTS OF


SIGNALS/SEQUENCES AND REAL AND IMAGINARY
PART OF SIGNAL

AIM: To find even and odd parts of signals and sequences and real and
imaginary part of signals and sequences.
SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
One of characteristics of signal is symmetry that may be useful for signal
analysis. Even signals are symmetric around vertical axis, and Odd signals are
symmetric about origin.

Even Signal:
A signal is referred to as an even if it is identical to its time-reversed

counter parts; x(t) = x(-t).

Odd Signal:

A signal is odd if x(t) = -x(-t).


An odd signal must be 0 at t=0, in other words, odd signal passes the origin.

Using the definition of even and odd signal, any signal may be
decomposed into a sum of its even part, xe(t), and its odd part, xo(t), as
follows:

xe(t)=1/2{x(t)+x(-t)}
xo(t)=1/2{x(t)-x(-t)}

35
BS LAB [Type here] 23011A0420

x(t)=xe(t)+xo(t)

The real and imaginary parts of a signal are components of a complex-valued


signal, which is typically represented as:
x(t) = Re(x(t))+jImg(x(t))

where,
Re(x(t)): The real part of the signal, which consists of the values along the real
axis.
Img(x(t)): The imaginary part of the signal, which consists of the values along the
imaginary axis.
j: The imaginary unit (j^2=-1).

1. Real Part:
The real part of a complex signal often corresponds to the physically measurable
part, such as amplitude or displacement. It can be extracted using:
Re(x(t))=(x(t)+x*(t))/2

2. Imaginary Part:
The imaginary part is orthogonal to the real part and is often related to the
phase information. It can be extracted using:
Img(x(t))=(x(t)-x*(t))/2i

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

36
BS LAB [Type here] 23011A0420

PROGRAM_1:
%To find even and odd parts of signal and real and imaginary parts of signal
clc; clear all; close all;
figure;

%To find even and odd parts of a signal

t=-2:0.01:2;
y1=0.*(t>=-2 & t<0) + 2.*(t>=0 & t<=2);
subplot(2,2,1);
plot(t,y1); axis([-3,3,-3,3]); grid on;
title("original signal"); xlabel("time"); ylabel("Amplitude");

%time reversal or floded signal


y2 = fliplr(y1);
subplot(2,2,2);
plot(t,y2); axis([-3,3,-3,3]); grid on;
title("Time reversal signal"); xlabel("time"); ylabel("Amplitude");

%even signal
y3= 0.5.*(y1+y2);
subplot(2,2,3);
plot(t,y3); axis([-3,3,-3,3]); grid on;
title("Even part of the signal"); xlabel("time"); ylabel("Amplitude");

%odd signal
y4= 0.5.*(y1-y2);
subplot(2,2,4);
plot(t,y4); axis([-3,3,-3,3]); grid on;
title("Odd part of the signal"); xlabel("time"); ylabel("Amplitude");

%Finding Real and Imaginary parts of a signal

figure;
t1=0:0.01:4*pi;
y= sin(t1)+j.*cos(t1);

37
BS LAB [Type here] 23011A0420

subplot(3,1,1);
plot(t1,y); grid on;
title("Original complex signal "); xlabel("time"); ylabel("Amplitude");

subplot(3,1,2);
plot(t1,real(y)); grid on;
title("Real part of the signal "); xlabel("time"); ylabel("Amplitude");

subplot(3,1,3);
plot(t1,imag(y)); grid on;
title("Imaginary part of the signal "); xlabel("time"); ylabel("Amplitude");

OUTPUT:

38
BS LAB [Type here] 23011A0420

PROGRAM_2:
%To find even and odd parts of sequence and real and imaginary parts of
sequence
clc; clear all; close all;
figure;

%To find even and odd parts of a sequence

n=-2:1:2;
y1=0.*(n>=-2 & n<0) + 2.*(n>=0 & n<=2);
subplot(2,2,1);
stem(n,y1); axis([-3,3,-3,3]); grid on;
title("original sequence"); xlabel("n"); ylabel("Amplitude");

%time reversal or floded sequence


y2 = fliplr(y1);
subplot(2,2,2);
stem(n,y2); axis([-3,3,-3,3]); grid on;
title("Time reversal sequence"); xlabel("n"); ylabel("Amplitude");

%even sequence
y3= 0.5.*(y1+y2);
subplot(2,2,3);
stem(n,y3); axis([-3,3,-3,3]); grid on;
title("Even part of the sequence"); xlabel("n"); ylabel("Amplitude");
39
BS LAB [Type here] 23011A0420

%odd sequence
y4= 0.5.*(y1-y2);
subplot(2,2,4);
stem(n,y4); axis([-3,3,-3,3]); grid on;
title("Odd part of the sequence"); xlabel("n"); ylabel("Amplitude");

%Finding Real and Imaginary parts of a sequence

figure;
n1=0:1:4*pi;
y= sin(n1)+j.*cos(n1);

subplot(3,1,1);
stem(n1,y); grid on;
title("Original complex sequence "); xlabel("n"); ylabel("Amplitude");

subplot(3,1,2);
stem(n1,real(y)); grid on;
title("Real part of the sequence "); xlabel("n"); ylabel("Amplitude");

subplot(3,1,3);
stem(n1,imag(y)); grid on;
title("Imaginary part of the sequence "); xlabel("n"); ylabel("Amplitude");
OUTPUT:

40
BS LAB [Type here] 23011A0420

RESULT:
Hence, even and odd parts of signal and real and imaginary parts of signal and
sequences are performed and generated using MATLAB

41
BS LAB [Type here] 23011A0420

Experiment No.:5

CONVOLUTION FOR SIGNALS AND SEQUENCES

AIM: Convolution for signals and sequences.


SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
Convolution

Convolution is the basic concept in signal processing that states an input


signal can be combined with the system's function to find the output
signal. It is the integral of the product of two waveforms after one has
reversed and shifted; the symbol for convolution is

That is the convolution integral and is used to find the convolution of a


signal and a system; typically a = -∞ and b = +∞.

Consider two waveforms f and g. By calculating the convolution, we


determine how much a reversed function g must be shifted along the x-
axis to become identical to function f. The convolution function essentially
reverses and slides function g along the axis, and calculates the integral of
their (f and the reversed and shifted g) product for each possible amount
of sliding. When the functions match, the value of (f*g) is maximized. This
occurs because when positive areas (peaks) or negative areas (troughs) are
multiplied, they contribute to the integral.

Convolution involves the following operations.


1. Folding
2. Multiplication
42
BS LAB [Type here] 23011A0420

3. Addition

Y[n]=T∑𝑘=−∞ 𝑥[𝑘] 𝛿(𝑛 − 𝑘)


4. Shifting

These operations can be represented by a Mathematical


Expression as follows:
x[n]= Input signal Samples
h[n-k]=impulse response coefficient
y[n]=convolution output
n=no.of input samples
h=no.0f impulse response coefficient
example:X(n)={1 2 -1 0 1},h(n)={1 2 3 -1}

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM_1:
%Convolution of signals
clc; clear all; close all;

%Generation of sine signal


f=0.1;
t=0:1:100;
y1=sin(2*pi*f*t);
subplot(3,1,1);
plot(t,y1); grid on;
title("sine signal(y1)"); xlabel("time"); ylabel("amplitude");
43
BS LAB [Type here] 23011A0420

%Generation of cosine signal


f=0.1;
t=0:1:100;
y2=cos(2*pi*f*t);
subplot(3,1,2);
plot(t,y2); grid on;
title("cosine signal(y2)"); xlabel("time"); ylabel("amplitude");

%generation of convolution signal of y1*y2


f=0.01;
t=0:1:100;
y=conv(y1,y2,"same");
subplot(3,1,3);
plot(t,y); grid on;
title("convolution of y1*y2 signal"); xlabel("time"); ylabel("amplitude");

OUTPUT:

PROGRAM_2:
%Convolution of sequences
clc; clear all; close all;

%Generation of sine sequences


44
BS LAB [Type here] 23011A0420

f=0.1
n=0:1:100;
y1=sin(2*pi*f*n);
subplot(3,1,1);
stem(n,y1); grid on;
title("sine sequence(y1)"); xlabel("time"); ylabel("amplitude");

%Generation of cosine sequence


f=0.1;
n=0:1:100;
y2=cos(2*pi*f*n);
subplot(3,1,2);
stem(n,y2); grid on;
title("cosine sequence(y2)"); xlabel("time"); ylabel("amplitude");

%generation of convolution sequence of y1*y2


f=0.01;
n=0:1:100;
y=conv(y1,y2,"same");
subplot(3,1,3);
stem(n,y); grid on;
title("convolution of y1*y2 signal"); xlabel("time"); ylabel("amplitude");

OUTPUT:

45
BS LAB [Type here] 23011A0420

RESULT:
Hence, convolution of two signals and sequences are
performed and generated using MATLAB.

Experiment No.:6
46
BS LAB [Type here] 23011A0420

AUTO CORRELATION AND CROSS CORRELATION FOR


SIGNALS AND SEQUENCES

AIM: To preform auto correlation and cross corelation of signals and


sequences.
SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
Cross-correlation:
The cross-correlation between two different signals or functions or waveforms is
defined as the measure of similarity or coherence between one signal and the
time-delayed version of another signal. The cross-correlation between two
different signals indicates the degree of relatedness between one signal and the
time-delayed version of another signal.
The cross-correlation of energy (or aperiodic) signals and power (or periodic)
signals is defined separately.
Cross-correlation of Energy Signals:
Consider two complex signals x1(t) and x2(t) of finite energy. Then, the cross-
correlation of these two energy signals is defined as

If the two signals x1(t) and x2(t) are real, then the cross-correlation between
them is,

If the energy signals x1(t) and x2(t) have some similarity. Then, the cross-
correlation R12(τ) between them will have some finite value over the range τ.
The variable τ is called the delay parameter or searching parameter or scanning
parameter. The time-delay parameter (τ) is the time delay or time shift of one of

47
BS LAB [Type here] 23011A0420

the two signals. This delay parameter τ determines the correlation between two
signals.
Cross-correlation of Power Signals:
The cross-correlation R12(τ) for two power (or periodic) signals x1(t) and x2(t)
may be defined using the average form of correlation. If two power signals x1(t)
and x2(t) have the same time period (say T), then the cross-correlation between
them is defined as follows −

Auto correlation:
The autocorrelation function is defined as the measure of similarity or
coherence between a signal and its time delayed version. Therefore, the
autocorrelation is the correlation of a signal with itself.
Like cross-correlation, autocorrelation is also defined separately for energy (or
aperiodic) signals and power (periodic) signals.
Autocorrelation of Energy Signals:
The autocorrelation of an energy or aperiodic signal x(t)x(t) is defined as −

Where, the variable τ is called the delay parameter and here, the signal x(t) is
time shifted by τ units in the positive direction.
If the signal x(t) is shifted by τ units in negative direction, then the
autocorrelation of the signal is defined as,

Autocorrelation of Power Signals:


The autocorrelation of a power signal or periodic signal x(t) having a time period
T is defined as,

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
48
BS LAB [Type here] 23011A0420

Save the program with .m extension.


 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM_1:
%Auto Correlation and Cross Correlation for signals
clc; clear all; close all;
figure;

t=0:0.01:2*pi;
x=sin(t);
y=cos(t);
u=autocorr(x);
v=xcorr(x,y);

subplot(2,2,1);
plot(t,x); grid on;
title("Original signal x"); xlabel("time"); ylabel("Amplitude");

subplot(2,2,2);
plot(t,y); grid on;
title("Original Signal y"); xlabel("time"); ylabel("Amplitude");

subplot(2,2,3);
plot(u); grid on;
title("Autocorrelation of x signal"); xlabel("time"); ylabel("Amplitude");

subplot(2,2,4);
plot(v); grid on;
title("cross correlation of x and y "); xlabel("time"); ylabel("Amplitude");

OUTPUT:
49
BS LAB [Type here] 23011A0420

PROGRAM_2:
%Auto Correlation and Cross Correlation for sequence
clc; clear all; close all;
figure;

n=0:1:2*pi;
x=sin(n);
y=cos(n);
u=autocorr(x);
v=xcorr(x,y);

subplot(2,2,1);
stem(n,x); grid on;
title("Original sequence x"); xlabel("n"); ylabel("Amplitude");

subplot(2,2,2);
stem(n,y); grid on;
title("Original sequence y"); xlabel("n"); ylabel("Amplitude");

subplot(2,2,3);
stem(u); grid on;
title("Autocorrelation of x sequence"); xlabel("n"); ylabel("Amplitude");

50
BS LAB [Type here] 23011A0420

subplot(2,2,4);
stem(v); grid on;
title("cross correlation of x and y"); xlabel("n"); ylabel("Amplitude");

OUTPUT:

RESULT:
Hence, auto correlation and cross correlation of signals and sequences are
performed and generated using MATLAB.

51
BS LAB [Type here] 23011A0420

Experiment No.:7

VERIFICATION OF LINEARITY AND TIME INVARIANCE


PROPERTIES OF A GIVEN CONTINUOUS/DISCRETE
SYSTEMS

AIM: To verify linearity and time invariance properties of a continuous/discrete


systems.
SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
System − An entity which acts on an input signal and transforms it into an
output signal is called the system.
Linear System
A linear system is defined as a system for which the principle of superposition
and the principle of homogeneity are valid.
Superposition Principle:The principle of superposition states that the response
of the system to a weighted sum of input signals is equal to the corresponding
weighted sum of the outputs of the system to each of the input signals.
Therefore, if an input signal x1(t) produces an output signal y1(t) and another
input signal x2(t) produces an output y2(t), then the system is said to be linear if,

Where,a and b are constants.

Types of Linear Systems


Linear systems can be of the following two types −
 Linear Time-Invariant [LTI] System
 Linear Time-Variant [LTV] System
Linear Time Invariant (LTI) System

52
BS LAB [Type here] 23011A0420

A system which is both linear and time-invariant is called the linear time
invariant system. In other words, a system for which both the superposition
principle and the homogeneity principle are valid and the input-output
characteristics of the system do not change with time is called linear time
invariant (LTI) system.
Therefore, for an LTI system, the output for a delayed input [x(t -t0)] must equal
to the delayed output [y(t -t0)], i.e.,

It means that if the input to the system is delayed by (t 0) units, then the
corresponding output will also be delayed by(t o) units. Also, for a linear time
invariant system, all the coefficients of the differential equation describing the
system are constants.

Linear Time-Variant (LTV) System


A system which is linear but time-variant is called the linear time-variant
system. In other words, a system for which the principle of superposition and
homogeneity are valid but the input-output characteristics change with time is
called the linear time-variant (LTV) system.
Therefore, for a linear time variant (LTV) system, the output of the system
corresponding to the delayed input signal [i.e.,x(t -t0)] is not equal to the delayed
output [y(t -t0)], i.e.,

It means that, if the input to an LTV system is delayed by (t0) units, then the
corresponding output will not be delayed by exactly (t0) units. Also, for a linear
time variant (LTV) system at least one of the coefficients of the differential
equation describing the system vary with time.

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
53
BS LAB [Type here] 23011A0420

 Write the program in TEXT EDITOR window.


 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM_1:
%verification of linearity of systems

clc; close all; clear all;

x1=input("Enter the samples of sequence x1 in []:");


x2=input("Enter the samples of sequence x2 in []:");

a1=input("enter the scaling constant a1 value:");


a2=input("enter the scaling constant a2 value:");

m=length(x1);
n=length(x2);
if (m>n)
x2=[x2,zeros(1,m-n)];
else
x1=[x1,zeros(1,n-m)];
end
disp(x1);
disp(x2);
x=a1*x1+a2*x2;
y=2*x;%system output is y
y1=2*a1*x1;
y2=2*a2*x2;%individual outputs y1,y2 for the inputs x1 and x2
z=y1+y2;
disp("output y=2x=");disp(y);
disp("sum of individual outputs z=y1+y2=");disp(z);

54
BS LAB [Type here] 23011A0420

if (y==z)
disp("System is Linear")
else
disp("system is Non-linear");
end;
%verfication of Linearity for system2
disp("verfication of Linearity for system2");
x=a1*x1+a2*x2;
y = x.^2;
y21 = a1*(x1.^2);
y22 = a2*(x2.^2);
z =y21+y22;
disp("output y=x^2=");disp(y);
disp("sum of individual outputs z=y21+y21=");disp(z);
if (y==z)
disp("System is linear")
else
disp("system is Non-linear");
end;

OUTPUT:

Enter the samples of sequence x1 in []:[2 3 4 5 6]


Enter the samples of sequence x2 in []:[5 6 7]
enter the scaling constant a1 value:3
enter the scaling constant a2 value:4
2 3 4 5 6

5 6 7 0 0

output y=2x=
52 66 80 30 36

sum of individual outputs z=y1+y2=


52 66 80 30 36

System is Linear
verfication of Linearity for system2
55
BS LAB [Type here] 23011A0420

output y=x^2=

PROGRAM_2:
%verification of Time invariance of a system

clc; close all; clear all;

disp("Verfication of time invariance for system1");


disp("------------------------------------------")
d=2; %delay time
x=[1 2 3 4 5 6 7 8 9];
y=x.^2;
xd=[zeros(1,d),x];%input delayed by d units
yd1= xd.^2;%output due to delayed input
yd2=[zeros(1,d),y];% output delayed by d units
disp("output due to delayed input yd1=");disp(yd1);
disp("delayed output yd2=");disp(yd2);
if (yd1==yd2)
disp("system is time-invariant ");
else
disp("system is time-variant");
end;

%verification for system2


disp("Verfication of time invariance for system2");
disp("------------------------------------------")
n=1:1:9;
y=n.*x;
xd=[zeros(1,d),x];%input delayed by d units
n1=1:1:length(xd);
yd1= n1.*xd;%output due to delayed input
yd2=[zeros(1,d),y];% output delayed by d units
disp("output due to delayed input yd1=");disp(yd1);
disp("delayed output by d units, yd2=");disp(yd2);
if (yd1==yd2)
disp("system is time-invariant ")
else

56
BS LAB [Type here] 23011A0420

disp("system is time-variant")
end;

OUTPUT:

Verfication of time invariance for system1


------------------------------------------
output due to delayed input yd1=
0 0 1 4 9 16 25 36 49 64 81

delayed output yd2=


0 0 1 4 9 16 25 36 49 64 81

system is time-invariant
Verfication of time invariance for system2
------------------------------------------
output due to delayed input yd1=
0 0 3 8 15 24 35 48 63 80 99

delayed output by d units, yd2=


0 0 1 4 9 16 25 36 49 64 81

system is time-variant

RESULT:
Hence, linearity and time invariance properties of a continuous/discrete
system are verified.

57
BS LAB [Type here] 23011A0420

Experiment No.:8

COMPUTATION OF UNIT SAMPLE, UNIT STEP AND SINUSOIDAL


RESPONSES OF THE GIVEN LTI SYSTEM AND VERIFYING ITS
PHYSICAL REALIAZABILITY AND STABILITY PROPERTIES

AIM: To compute Unit sample, Unit step and Sinusoidal responses of


the given LTI system and verifying its physical realiazability and stability
properties.
SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
A discrete time system performs an operation on an input signal based on
predefined criteria to produce a modified output signal. The input signal x(n) is
the system excitation, and y(n) is the system response. The transform operation
is shown as,

If the input to the system is unit impulse i.e. x(n) = δ(n) then the output of the
system is known as impulse response denoted by h(n) where,
h(n) = T[δ(n)]
we know that any arbitrary sequence x(n) can be represented as a weighted sum
of discrete impulses. Now the system response is given by,

58
BS LAB [Type here] 23011A0420

For linear system (1) reduces to

%given difference equation y(n)-y(n-1)+.9y(n-2)=x(n);

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM:
%G=10/(s^2+2s+20)
clc;clear all;close all;
num=[10];
den=[1 2 20];

t=0:0.1:10
59
BS LAB [Type here] 23011A0420

%inputs
x1=1.*(t==0);
x2=1.*(t>0);
x3=sin(t);
sys=tf(num,den)
%system response
y1=lsim(sys,x1,t);
y2=lsim(sys,x2,t);
y3=lsim(sys,x3,t);

subplot(3,1,1);plot(t,y1);
xlabel('t');ylabel('y1');title('impulse response');
subplot(3,1,2);plot(t,y2);
xlabel('t');ylabel('y2');title('step response');
subplot(3,1,3);plot(t,y3);
xlabel('t');ylabel('y2');title('sine response');

OUTPUT:

60
BS LAB [Type here] 23011A0420

RESULT:
Hence, computation Unit sample, Unit step and Sinusoidal responses
of the given LTI system is performed and generated using MATLAB.
Experiment No.:9

GIBBS PHENOMENON SIMULATION

AIM: Simulation of gibbs phenomenon.


SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
Gibbs Phenomenon:
The Gibbs phenomenon, the Fourier series of a piecewise continuously
differentiable periodic function behaves at a jump discontinuity. The n the
approximated function shows amounts of ripples at the points of discontinuity.
This is known as the Gibbs Phenomina . partial sum of the Fourier series has
large oscillations near the jump, which might increase
The maximum of the partial sum above that of the function itself. The overshoot
does not die out as the frequency increases, but approaches a finite limit
The Gibbs phenomenon involves both the fact that Fourier sums overshoot at a
jump discontinuity, and that this overshoot does not die out as the frequency
increases.

61
BS LAB [Type here] 23011A0420

Gibbs Phenomenon is used to convert the sine wave in to square wave by


adding the number of harmonics to the sine wave using fourier series. if you
give the highest number of harmonics (32or 64) the output graphs show how
gradually the sine converts in to square wave. From a signal processing point of
view, the Gibbs phenomenon is the step response of a low-pass filter, and the
oscillations are called ringing or ringing artifacts. Truncating the Fourier
transform of a signal on the real line, or the Fourier series of a periodic signal
(equivalently, a signal on the circle) corresponds to filtering out the higher
frequencies by an ideal (brick-wall) low-pass/high-cut filter.
This can be represented as convolution of the original signal with the impulse
response of the filter (also known as the kernel), which is the sinc function. Thus
the Gibbs phenomenon can be seen as the result of convolving a Heaviside step
function (if periodicity is not required) or a square wave (if periodic) with a sinc
function: the oscillations in the sinc function cause the ripples in the output.

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
62
BS LAB [Type here] 23011A0420

 Close the MATLAB tool properly.


 Switch of the system properly.

PROGRAM:
clc;clear all;close all;

t=0:0.01:2*pi;
y1=sin(t);
y2=sin(3*t)/3;
y3=sin(5*t)/5;
y4=sin(7*t)/7;
y5=sin(9*t)/9;
y6=sin(11*t)/11;

subplot(2,2,1);
plot(t,y1,t,y2,t,y3,t,y1+y2+y3);
title("with 3 freqs");
grid on;
legend('y1','y2','y3','y');
subplot(2,2,2);
plot(t,y1,t,y2,t,y3,t,y4,t,y1+y2+y3+y4);
title("with 4 freqs");
grid on;
legend('y1','y2','y3','y4','y');
subplot(2,2,3);
plot(t,y1,t,y2,t,y3,t,y4,t,y5,t,y1+y2+y3+y4+y5);

63
BS LAB [Type here] 23011A0420

title("with 5 freqs");
grid on;
legend('y1','y2','y3','y4','y5','y');
subplot(2,2,4);
plot(t,y1,t,y2,t,y3,t,y4,t,y5,t,y6,t,y1+y2+y3+y4+y5+y6);
title("with 6 freqs");
grid on;
legend('y1','y2','y3','y4','y5','y6','y');
figure;
y1=0;
for n=1:2:100
y1=y1+sin(n*t)/n;
end
plot(t,y1);

OUTPUT:

64
BS LAB [Type here] 23011A0420

65
BS LAB [Type here] 23011A0420

RESULT:
Hence, gibbs phenomenon is simulated.

Experiment No.:10

FINDING THE FOURIER TRANSFORM OF A GIVEN


SIGNAL AND PLOTTING ITS MAGNITUDE AND PHASE
SPECTRUM

AIM: To find the Fourier Transform of a given signal and plotting its magnitude
and phase spectrum.
SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:

66
BS LAB [Type here] 23011A0420

The Fourier transform (FT) decomposes a function of time (a signal) into its
constituent frequencies. This is similar to the way a musical chord can be
expressed in terms of the volumes and frequencies of its constituent notes. The
term Fourier transform refers to both the frequency domain
representationandthemathematicaloperationthatassociatesthefrequencydomain
representationto a function of time. The Fourier transform of a function of
time is itself a complex-valued function of frequency, whose magnitude
(modulus) represents the amount of that frequency present in the original
function, and whose argument is the phase offset of the basic
sinusoid in that frequency. The Fourier transform is not limited to functions of
time, but the domain of the original function is commonly referred to as the
time domain. There is also an inverse Fourier transform that mathematically
synthesizes the original function from its frequency domain representation.
Linear operations performed in one domain (time or frequency) hae
corresponding operations in the other domain, which are sometimes easier to
perform. The operation of differentiation in the time domain corresponds to
multiplication by the frequency, [remark1] so some differential equations are
easier to analyze in the frequency domain. Also, convolution in the time domain
corresponds to ordinary multiplication in the frequency domain (see
Convolution theorem). After performing the desired operations, transformation
of the result can be made back to the time domain. Harmonic analysis is the
systematic study of the relationship between the frequency and time domains,
including the kinds of functions or operations that are & quot; simpler& quot; in
one or the other, and has deep connections to many areas of modern
mathematics.
FORMULA:

67
BS LAB [Type here] 23011A0420

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM:
clc;clear all;close all;
syms t;
x= (exp(-2*t))*heaviside(t);
x1=simplify(x);
disp("input signal");
disp(x1);
y=fourier(x1);
y1=simplify(y);
disp("fourier transform of x1")
disp(y1);
mag=sqrt((real(y1)).^2+(imag(y1)).^2);
disp("magnitude ")
disp(mag);
disp("phase angle");
ang = (angle(y1))*180/pi;
68
BS LAB [Type here] 23011A0420

disp(ang);
subplot(3,1,1)
ezplot(x1)
xlabel("frequency w (rad/sec)")
ylabel("Amplitude")
title("input signal")
subplot(3,1,2)
ezplot(mag,[-10 10])
xlabel("frequency w (rad/sec)")
ylabel("Magnitude")
title("Magnitude spectrum")
subplot(3,1,3)
ezplot(ang,[-10,10])
xlabel("frequency w (rad/sec)")
ylabel("angle in degrees")
title("Phase spectrum")

OUTPUT:

69
BS LAB [Type here] 23011A0420

input signal
exp(-2*t)*heaviside(t)
fourier transform of x1
1/(2 + w*1i)
magnitude
(real(1/(2 + w*1i))^2 + imag(1/(2 + w*1i))^2)^(1/2)
phase angle
(180*angle(1/(2 + w*1i)))/pi
RESULT:
Hence, the Fourier Transform of a Signal is found and Waveforms of its
Magnitude and Phase Responses are observed.
Experiment No.:11

WAVEFORM SYNTHESIS USING LAPLACE


TRANSFORM
70
BS LAB [Type here] 23011A0420

AIM: Waveform Synthesis using Laplace Transform.


SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
laplace transform :
The bilateral Laplace transform is defined as follows:

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM:
clc;clear all;close all;
syms t s;
f0=heaviside(t);
f1=heaviside(t-1);
f2=heaviside(t-2);
71
BS LAB [Type here] 23011A0420

f3=heaviside(t-3);
f4=heaviside(t-4);
f5=heaviside(t-5);
f= (f0-f1)+(f2-f3)+(f4-f5);
display("input waveform ");
display(f);
subplot(3,1,1);fplot(f);title("square waveform");
axis([-10,10,-2,2]);grid on;
L0=laplace(f0);
L1=laplace(f1);
L2=laplace(f2);
L3=laplace(f3);
L4=laplace(f4);
L5=laplace(f5);

L= L0+L1+L2+L3+L4+L5;
Lt= collect(L);
Lt1=simplify(Lt);

display(Lt1);
subplot(3,1,2);
ezplot(Lt1); title("Laplace transform of square waveform");

OUTPUT:

72
BS LAB [Type here] 23011A0420

"input waveform "


f=
heaviside(t - 2) - heaviside(t - 1) - heaviside(t - 3) + heaviside(t - 4) - heaviside(t -
5) + heaviside(t)
Lt1 =
(exp(-s) + exp(-2*s) + exp(-3*s) + exp(-4*s) + exp(-5*s) + 1)/s

RESULT:
Hence, Waveform Synthesis using Laplace Transform is performed and
generated using MATLAB.

Experiment No.:12

73
BS LAB [Type here] 23011A0420

LOCATING THE ZEROS AND POLES AND PLOTTING


THE POLE-ZERO MAPS IN S-PLANE AND Z-PLANE FOR
THE GIVEN TRANSFER FUNCTION

AIM: To locate the Zeros and Poles and plotting the Pole-Zero maps in S-plane
and Z-Plane for the given transfer function.
SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
The Laplace transform can be used to solve differential equations. Besides
being a different and efficient alternative to variation of parameters and
undetermined coefficients, the Laplace method is particularly advantageous
for input terms that are piecewise-defined, periodic or impulsive. The direct
Laplace transform or the Laplace integral of a function f(t) defined for 0 ≤ t &
lt; ∞ is the ordinary calculus integration L–notation recognizes that
integration always proceeds over t = 0 to t= ∞ and that the integral involves
an integrator instead of the usual dt. These minor differences distinguish
Laplace integrals from the ordinary integrals found on the inside covers of
calculus texts. Lerch’s law, the formal rule of erasing the integral signs is valid
provided the integrals are equal for large s and certain conditions hold on y

FORMULA:

In the study of discrete-time signal and systems, we have thus far


considered the time-domain and the frequency domain. The z domain gives
us a third representation. All three domains are related to each other. A
special feature of the z-transform is that for the signals and system of interest
to us, all of the analysis will be in terms of ratios of polynomials. Working with
74
BS LAB [Type here] 23011A0420

these polynomials is relatively straight forward.


Definition of the z-Transform
• This transformation produces a new representation of denoted
• Returning to the original sequence (inverse z-transform)
requires finding the coefficient associated with the nth
power.
– In the sequence or n-domain the independent variable is n
– In the z-domain the independent variable is z

FORMULA:

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM_1:
%Locating zeros and poles and plotting pole-zero map in S-plane
clc;clear all;close all;

syms s t;

75
BS LAB [Type here] 23011A0420

f=sin(t);
L=laplace(f);
L1=collect(L);
[num,den]=numden(L1);
num_coeff=sym2poly(num);
den_coeff=sym2poly(den);
trf=tf(num_coeff,den_coeff);

subplot(2,2,1);
ezplot(t,f);
xlabel("Time");
ylabel("Amplitude");
subplot(2,2,2);
ezplot(L1);
title("Laplace Transform");
subplot(2,2,3);
pzmap(trf)
xlabel('real(s)');
ylabel('img(s)');
title('Poles and Zeroes');

OUTPUT:

76
BS LAB [Type here] 23011A0420

PROGRAM_2:
%Locating zeros and poles and plotting pole-zero map in Z-plane
clc;clear all;close all;

syms n z;
f=sin(n);
z=ztrans(f,n,z);
Z1=collect(z);
[num,den]=numden(Z1);
num_coeff=sym2poly(num);
den_coeff=sym2poly(den);
trf=tf(num_coeff,den_coeff,0.01);

subplot(2,2,1);
ezplot(f,[0,10]);
77
BS LAB [Type here] 23011A0420

xlabel('n');
ylabel('Amplitude');
title('sin(n)');
subplot(2,2,2);
fplot(Z1,[0,10]);
xlabel('z');
ylabel('Z(z)');
title('Z Transform');
subplot(2,2,3);
pzmap(trf);
xlabel('Real(z)');
ylabel('Img(z)');
title('Poles and Zeroes in z-plane');

OUTPUT:

78
BS LAB [Type here] 23011A0420

RESULT:
Hence, located the Zeros and Poles and plotted the Pole-Zero maps in S-plane
and Z-Plane for the given transfer function using MATLAB.

79
BS LAB [Type here] 23011A0420

Experiment No.:13

GENERATION OF GAUSSIAN NOISE (REAL AND


COMPLEX), COMPUTATION OF ITS MEAN, M.S. VALUE
AND ITS SKEW, KURTOSIS, AND PSD, PROBABILITY
DISTRIBUTION FUNCTION

AIM: To generate gaussian noise ,Computation of its mean, M.S. Value and its
Skew, Kurtosis, and PSD, Probability Distribution Function.
SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
Gaussian noise is statistical noise that has a probability density function
(abbreviated pdf) of the normal distribution (also known as Gaussian
distribution). In other words, the values the noise can take on are Gaussian-
distributed. It is most commonly used as additive white noise to yield additive
white Gaussian noise (AWGN). Gaussian noise is properly defined as the noise
with a Gaussian amplitude distribution. says nothing of the correlation of the
noise in time or of the spectral density of the noise. Labeling Gaussian noise
as 'white' describes the correlation of the noise. It is necessary to use the
term "white Gaussian noise" to be correct. Gaussian noise is sometimes
misunderstood to be white Gaussian noise, but this is not the case.

FORMULA:
Gaussian Noise,

Where, 𝜇= mean
𝜎 = 𝑆𝑡𝑎𝑛𝑑𝑎𝑟𝑑𝐷𝑒𝑣𝑖𝑎𝑡𝑖𝑜𝑛
80
BS LAB [Type here] 23011A0420

𝜎2 = 𝑣𝑎𝑟𝑖𝑎𝑛𝑐𝑒

MATLAB command:
P = normpdf(x,yMu,ysigma)

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM:
clc;clear all;close all;

t=0:0.1:20;
s=sin(t);
x=randn(1,length(t));
ymu=mean(x)
ymse = sum(x.^2)/length(x)
ysigma = std(x)
yvar=var(x)
yskew= skewness(x)
ykurto= kurtosis(x)
81
BS LAB [Type here] 23011A0420

p=normpdf(x,ymu,ysigma);
subplot(2,2,1);
plot(x,'*');
title('scatter plot of gaussian distribution');
subplot(2,2,2);
area(x,p);
title('guassian noise distribution');
subplot(2,2,3);
area(t,s);
title('sin signal without noise');
subplot(2,2,4);
area(t,s+0.3*x-0.15);
title('sin signal with added noise')

OUTPUT:
ymu =
0.0260
ymse =
1.1734
ysigma =
1.0856
yvar =
1.1785
yskew =
0.2589

82
BS LAB [Type here] 23011A0420

ykurto =
3.3594

RESULT:
Hence, the gaussian noise is generated and its pdf, mean, variance, skewness,
kurtosis parameters are studied and output signals are observed in MATLAB.

83
BS LAB [Type here] 23011A0420

Experiment No.:14

VERIFICATION OF SAMPLING THEOREM

AIM: To verify sampling theorem.


SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
The Sampling Theorem

The sampling theorem is an important aid in the design and analysis of


communication systems involving the use of continuous time functions of
finite bandwidth. The theorem states that, if a function of time, f(t), contains
no frequencies of W hertz or higher, then it is completely determined by
giving the value of the function at a series of points spaced (2W)−1 seconds
apart. The sampling rate of 2W samples per second is called the Nyquist rate.

The sampling theorem specifies the minimum-sampling rate at which a


continuous-time signal needs to be uniformly sampled so that the original
signal can be completely recovered or reconstructed by these samples alone.
This is usually referred to as Shannon's sampling theorem in the literature.

If a continuous time signal contains no frequency components higher than


fm Hz, then it can be completely determined by uniform samples taken at a
rate fs samples per second where
Fs >= 2 x fm
or, in term of the sampling period

Undersampling

When a bandpass signal is sampled slower than its Nyquist rate, the samples

84
BS LAB [Type here] 23011A0420

are indistinguishable from samples of a low-frequency alias of the high-


frequency signal. That is often done purposefully in such a way that the
lowest-frequency alias satisfies the Nyquist criterion, because the bandpass
signal is still uniquely represented and recoverable. Such undersampling is
also known as bandpass sampling, harmonic sampling, IF sampling, and direct
IF to digital conversion.

Oversampling
Oversampling is used in most modern analog-to-digital converters to reduce
the distortion introduced by practical digital-to-analog converters, such as a
zero-order hold instead of idealizations like the Whittaker–Shannon
interpolation formula.
Critical Sampling
fs=2x fm

A bandlimited signal can be reconstructed exactly if it is sampled at a rate


atleast twice the maximum frequency component in it." Figure 1 shows a
signal g(t) that is band limited.

Figure 1: Spectrum of band limited signal g(t)

The maximum frequency component of g(t) is fm. To recover the signal g(t)
exactly from its samples it has to be sampled at a rate fs ≥ 2fm.
The minimum required sampling rate fs = 2fm is called ' Nyquist rate’.

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
85
BS LAB [Type here] 23011A0420

 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM:
clc; clear all; close all;

tp=0.05;
t=0:0.0005:tp;
fm=input("enter the analog signal frequency:");
xa=cos(2*pi*fm*t);
fsu=1.3*fm;
fsc=2*fm;
fso=10*fm;
nu=0:1/fsu:tp;
nc=0:1/fsc:tp;
no=0:1/fso:tp;
xu=cos(2*pi*fm*nu);
xc=cos(2*pi*fm*nc);
xo=cos(2*pi*fm*no);
subplot(3,1,1);plot(t,xa,'b',nu,xu,'r*-');title("under sampling");
subplot(3,1,2);plot(t,xa,'b',nc,xc,'r*-');title("critical sampling");
subplot(3,1,3);plot(t,xa,'b',no,xo,'r*-');title("over sampling");

86
BS LAB [Type here] 23011A0420

OUTPUT:
enter the analog signal frequency:50

RESULT:
Hence, verified sampling theorem using MATLAB.

87
BS LAB [Type here] 23011A0420

Experiment No.:15

REMOVAL OF NOISE BY AUTOCORRELATION /


CROSS CORRELATION

AIM: To remove noise by auto correlation or cross correlation.


SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
Noise removal using autocorrelation leverages the property that a signal's
autocorrelation function will reveal repeating patterns within itself, allowing
us to identify and isolate the signal from uncorrelated noise, which typically
has a low or near-zero autocorrelation value at non-zero lags; essentially, by
calculating the autocorrelation of a noisy signal, you can extract the periodic
components (signal) while minimizing the random noise influence.

1.Calculate the autocorrelation: Compute the autocorrelation function of the


noisy signal at different time lags.

2. Identify signal characteristics: Analyze the autocorrelation function to


identify the dominant period or repeating pattern of the signal.

3. Filter based on autocorrelation: Apply a filter based on the identified signal


characteristics to selectively amplify the signal components while attenuating
the noise components.

Noise removal using cross-correlation works by simultaneously measuring two


signals containing the same desired signal but different uncorrelated noise
components, then calculating the cross-correlation between them, which
effectively cancels out the uncorrelated noise while preserving the common
signal, leading to a cleaner signal with a significantly improved signal-to-noise
88
BS LAB [Type here] 23011A0420

ratio.

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.
 Create new program from NEW option in FILE menu.
 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM:
clc;clear all; close all;

N=1024; % Number of samples to generate


f1=1; % Frequency of the sinewave
FS=200; % Sampling frequency
n=0:N-1; % Sampling index
x=sin(2*pi*f1*n/FS); % Generate x(n)
y=x+randn(1,N); % Generate y(n)

subplot(3,1,1);
plot(x);
title('Pure Sinewave');
grid on;
89
BS LAB [Type here] 23011A0420

subplot(3,1,2);
plot(y);
title('y(n), Pure Sinewave + Noise');
grid on;
[Rxy,Lags]=xcorr(x,y,'normalized'); % Estimate the cross correlation
subplot(3,1,3);
plot(Rxy);
title('Cross correlation Rxy');
grid on;

OUTPUT:

RESULT:
Hence, removal of noise by auto correlation or cross correlation is performed
and generated by MATLAB.
90
BS LAB [Type here] 23011A0420

Experiment No.:16

VERIFICATION OF WEINER-KHINCHINE
RELATIONS

AIM: To verify Weiner-Khinchine Relations.


SOFTWARE REQUIRED:
1.MATLAB R2024a or 2024b
THEORY:
The Wiener-Khinchin theorem, also known as the Wiener-Khinchin-Einstein
theorem or the Khinchin-Kolmogorov theorem, establishes a relationship
between the power spectral density (PSD) and autocorrelation function of a
random process:
Statement
The PSD of a wide-sense stationary random process is equal to the Fourier
transform of the autocorrelation function of that process.
Significance
This theorem is important for analyzing stationary processes because it allows
you to characterize signals in both time and frequency domains.
Application
You can use the Wiener-Khinchin theorem to calculate a signal's PSD from its
autocorrelation, which gives you insights into how energy is distributed across
different frequencies.

PROCEDURE:
 Switch on the system with MATLAB tool.
 Launch MATLAB software by clicking on MATLAB icon on the desktop.

91
BS LAB [Type here] 23011A0420

 Create new program from NEW option in FILE menu.


 Write the program in TEXT EDITOR window.
 Save the program with .m extension.
 Run the program from the EDITOR menu or by pressing F5.
 Check the COMMAND window for output values/errors. If any errors are
there, debug the errors, modify the program and go to step6.
 Observe the text outputs in command window and graphical outputs in
FIGURES.
 Close the MATLAB tool properly.
 Switch of the system properly.

PROGRAM:
clc;clear all;close all;

t=0:0.1:2*pi;
x=sin(2*t);
subplot(3,2,1);
plot(x);
title("Sin Signal");
au=xcorr(x,x);
subplot(3,2,2);
plot(au);
title("Autocorrelated Signal");
v=fft(au);
subplot(3,2,3);
plot(abs(v));
title("Power Spectral Density");
fw=fft(x);
subplot(3,2,4);
92
BS LAB [Type here] 23011A0420

plot(fw);
title("Fast Fourier Transform - Magnitude Spectrum");
fw2=(abs(fw)).^2;
subplot(3,2,5);
plot(fw2);
title("Power Spectrum of given Sin Signal")

OUTPUT:

RESULT:
Hence, Weiner-Khinchine Relations are verified using MATLAB.

93

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy