BS - Record - 2
BS - Record - 2
Experiment No.:1
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:
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
r(n)= n for n = 0
= 0 for n < 0
Unit step signal means the signal has unit amplitude for
positive axis and has zero amplitude for negative axis.
r(n)= n for n =0
= 0 for n <0
7
BS LAB [Type here] 23011A0420
4. Exponential signal:
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:
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
PROGRAM_1:
%Generation of various signals
clc; clear all; close all;
OUTPUT:
PROGRAM_2:
%Generation of various signals using loops
clc; clear all; close all;
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");
OUTPUT:
PROGRAM_3:
%Generation of various signals using time basis
clc; clear all; close all;
subplot(3,3,3);
plot(t,y3);grid on;
title("square signal"); xlabel("time"); ylabel("amplitude");
OUTPUT:
PROGRAM_4:
%Generation of various sequences
clc; clear all; close all;
16
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");
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
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,
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.
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
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");
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");
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");
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");
OUTPUT:
PROGRAM_4:
%Compute energy and average power signals
clc; clear all; close all;
% Energy signal of y
energy=sum(abs(y).^2);
disp(['energy of y signal:',num2str(energy)])
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");
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");
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");
OUTPUT:
32
BS LAB [Type here] 23011A0420
PROGRAM_8:
%Compute energy and average power sequences
clc; clear all; close all;
% Energy sequence of y
energy=sum(abs(y).^2);
disp(['energy of y sequence:',num2str(energy)])
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
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
Odd Signal:
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)
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;
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");
%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");
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;
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");
%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");
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
3. Addition
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;
OUTPUT:
PROGRAM_2:
%Convolution of sequences
clc; clear all; close all;
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");
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
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,
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
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
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.
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
PROGRAM_1:
%verification of linearity of systems
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:
5 6 7 0 0
output y=2x=
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
56
BS LAB [Type here] 23011A0420
disp("system is time-variant")
end;
OUTPUT:
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
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
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
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
61
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.
62
BS LAB [Type here] 23011A0420
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
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
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
RESULT:
Hence, Waveform Synthesis using Laplace Transform is performed and
generated using MATLAB.
Experiment No.:12
73
BS LAB [Type here] 23011A0420
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:
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
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
Undersampling
When a bandpass signal is sampled slower than its Nyquist rate, the samples
84
BS LAB [Type here] 23011A0420
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
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
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;
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
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
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