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

DCSS lab part B Manual

The document outlines various experiments involving signal generation and manipulation using MATLAB, including periodic and aperiodic signals, operations on signals like addition and multiplication, and Fourier series analysis. It provides detailed MATLAB code for generating signals such as unit impulse, unit step, and sinusoidal functions, as well as performing operations like scaling and shifting. Additionally, it covers the Fourier Transform and its applications in analyzing signal magnitude and phase spectra.

Uploaded by

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

DCSS lab part B Manual

The document outlines various experiments involving signal generation and manipulation using MATLAB, including periodic and aperiodic signals, operations on signals like addition and multiplication, and Fourier series analysis. It provides detailed MATLAB code for generating signals such as unit impulse, unit step, and sinusoidal functions, as well as performing operations like scaling and shifting. Additionally, it covers the Fourier Transform and its applications in analyzing signal magnitude and phase spectra.

Uploaded by

charan gopavaram
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Generate various Signals and Sequences: Periodic

Ex.No: 01 Date :
and Aperiodic, Unit Impulse, Unit Step, Square, Saw
tooth, Triangular, Sinusoidal, Ramp, Sinc function

Aim: To write a Program to generate various signals and sequences, such as Perodic and Aperiodic
,unit impulse, unit step, unit ramp, sinusoidal, square, sawtooth, triangular, sinc signals.

Requirements:
PC with MATLAB software –R2023a

Theory:Unit Step Function

Unit step function is denoted by u(t). It is defined as u(t) = 1 t⩾0

0 t<0

Unit Impulse Function:


Impulse function is denoted by δ(t). and it is defined as δ(t) = 1 t=0
0 t ≠0

Ramp Signal:
Ramp signal is denoted by r(t), and it is defined as r(t) = t t⩾0
0 t<0
Sinc Function:

It is denoted as sinc(t) and it is defined as t=sin𝞹t/𝞹t

Program:
%periodic and aperiodic signals
clc;
clear all;
close all;
t=-10:0.01:10;
y=sin(t);
subplot(2,1,1);
plot(t,y);
xlabel('time axis');
ylabel('sine wave')
title('periodic signal');
R=rand(1,100);
subplot(2,1,2);
plot(R);
xlabel ('time axis');
ylabel('random signal')
title('aperiodic signal');
%unit impulse function
clc;
clear all;
close all;
t=-10:1:10;
x=(t==0);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit impulse
function');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit impulse discrete function');

%unit step function


clc;
clear all;
close all;
N=100;
t=1:100;
x=ones(1,N);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit step function');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit step discrete function');

%unit ramp function%


clc;
clear all;
close all;
t=0:20;
x=t;
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit ramp
function');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit ramp discrete function');

%sinusoidal function%
clc;
clear all;
close all;
t=0:0.01:2;
x=sin(2*pi*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sinusoidal signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('sinusoidal sequence');

%square function%
clc;
clear all;
close all;
t=0:0.01:2;
x=square(2*pi*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('square signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('square sequence');

%sawtooth function%
clc;
clear all;
close all;
t=0:0.01:2;
x=sawtooth(2*pi*5*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sawtooth signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('sawtooth sequence');

%trianguler function%
clc;
clear all;
close all;
t=0:0.01:2;
x=sawtooth(2*pi*5*t,0.5);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('trianguler signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('triangular sequence');
%sinc function%
clc;
clear all;
close
all;
t=linspace(-5,5);
x=sinc(t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sinc signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('sinc sequence');

OUTPUT:
Result:
Various types of signals are generated using MATLAB program.

Viva Questions:
1. Define Signal?
2. Define determistic and Random Signal?
3. Define Delta Function?
4. What is Signal Modeling?
5. Define Periodic and a periodic Signal?
Perform operations on Signals and Sequences:
Ex. No: 02 Date :
Addition, Multiplication, Scaling, Shifting, Folding,
Computation of Energy and Average Power

Aim: To perform the functions on signals and sequences such as addition, multiplication, scaling,
shifting, folding, computation of energy and average power.

Requirements:
PC with MATLAB software –R2023a

Theory:

Signal Addition: Any two signals can be added to form a third signal. z(t)= x(t) + y(t)

Multiplication: Multiplication of two signals can be obtained by multiplying the signal at every
instant z. z(t)= x(t) + y(t).

Time Reversal /Folding: Time reversal of x(t) is obtained by folding the signal about t=0.
Y(t)=y(-t).
Signal Amplification/scaling: Y(N)=ax(n) if a < 1, attenuation
a>1, amplification.
Time shifting: It is obtained by delay or advance the signal in time by using y(n)=x(n+k)
If k is positive number, y(n) is shifted to right (i.e) shifting delays the signal.
If k is negative number, y(n) gets shifted left (i.e) signal shifting advances the signal.
Program:
clc;
clear all;
close all;
% generating two input signals
t=0:.01:1;
xl=sin(2*pi*4*t);
x2=sin(2*pi*8*t);
subplot(2,2,1);
plot(t,xl);
xlabel('time');
ylabel('amplitude');
title('input signal 1');
subplot(2,2,2);
plot(t,x2);
xlabel('time');
ylabel('amplitude');
title('input signal 2');
% addition of signals
yl=xl+x2;
subplot(2,2,3);
plot(t,yl);
xlabel('time');
ylabel('amplitude');
title('addition of two signals');
% multiplication of signals
y2=xl.*x2;
subplot(2,2,4);
plot(t,y2);
xlabel('time');
ylabel('amplitude');
title('multiplication of two signals');
% scaling of a signall
A=2;
y3=A*xl;
figure;
subplot(2,2,1);
plot(t,xl);
xlabel('time');
ylabel('amplitude');
title('input signal')
subplot(2,2,2);
plot(t,y3);
xlabel('time');
ylabel('amplitude');
title('amplified input signal');
% folding of a signall
h=length(xl);
nx=0:h-1;
subplot(2,2,3);
plot(nx,xl);
xlabel('nx');
ylabel('amplitude');
title('input signal')
y4=fliplr(xl);
nf=-fliplr(nx);
subplot(2,2,4);
plot(nf,y4);
xlabel('nf');
ylabel('amplitude');
title('folded signal');
%shifting of a signal
figure;
subplot(3,1,1);
plot(t,xl);
xlabel('time t');
ylabel('amplitude');
title('input signal');
subplot(3,1,2);
plot(t+2,xl);
xlabel('t+2');
ylabel('amplitude');
title('right shifted signal');
subplot(3,1,3);
plot(t-2,xl);
xlabel('t-2');
ylabel('amplitude');
title('left shifted signal');
%operations on sequences
nl=1:1:9;
s1=[1 2 3 0 5 8 0 2 4];
figure;
subplot(2,2,1);
stem(nl,s1);
xlabel('nl');
ylabel('amplitude');
title('input sequence 1');
s2=[1 1 2 4 6 0 5 3 6];
subplot(2,2,2);
stem(nl,s2);
xlabel('n2');
ylabel('amplitude');
title('input sequence 2 ');
% addition of sequences
s3=s1+s2;
subplot(2,2,3);
stem(nl,s3);
xlabel('nl');
ylabel('amplitude');
title('sum of two sequences');
% multiplication of sequences
s4=s1.*s2;
subplot(2,2,4);
stem(nl,s4);
xlabel('nl');
ylabel('amplitude');
title('product of two sequences');
% program for energy of a sequence
zl=input('enter the input sequence');
el=sum(abs(zl).^2);
disp('energy of given sequence is');el
% program for energy of a signal
t=0:pi:10*pi;
z2=cos(2*pi*50*t).^2;
e2=sum(abs(z2).^2);
disp('energy of given signal is');e2
% program for power of a sequence
pl= (sum(abs(zl).^2))/length(zl);
disp('power of given sequence is');pl
% program for power of a signal
p2=(sum(abs(z2).^2))/length(z2);
disp('power of given signal is');p2

output:
enter the input sequence[1 3 2 4 1]
energy of given sequence is el = 31
energy of given signal is e2 = 4.0388
power of given sequence is pl =6.2000
power of given signal is p2 = 0.3672
Output:
Result:Various operations on signals and sequences are performed.

Viva Questions:

1.What is signal scaling?

2.Define signal folding.

3.State signal shifting.

4.Write an example for signal addition and multiplication.

5.Write formula for Energy andaverage power.


The trigonometric & exponential Fourier series
Ex. No: 03 Date :
coefficients of a rectangular periodic signal and
Reconstruct the output

Aim: To plot the trigonometric & exponential Fourier series coefficients of a periodic signal.

Requirements:
PC with MATLAB software –R2023a

Theory:

Fourier series:

Many physiological signals are somewhat repetitive: they repeat at regular intervals. The
processing and analysis and understanding of such signals is often facilitated by “breaking the
signal down” into its “component frequencies.It turns out that any periodic signal (one that repeats
itself at regular intervals) is equal to a sum of sines and cosines. The frequencies of the component
sines and cosines are just the frequency of the original periodic signal (the fundamental frequency),
plus the “overtones”, i.e. the integer multiples of the fundamental frequency.

If the period (repeat time) of the signal is T seconds, then the frequency (in cycles/sec, or Hertz) is
f=1/T. The sines and cosines will have frequencies of f, 2f, 3f, etc. For example, if the signal
repeats every 1.25 sec, f=0.8 Hz, and the component sines and cosines have frequencies of 0.8, 1.6,
2.4 Hz, etc.

(a) Trigonometric Fourier series: -The Fourier series is the set of sines and cosines that add up to
make a periodic signal.

(b) The exponential Fourier series: - Let f(t) be a periodic continuous time signal. Now the
exponential form of Fourier series of x(t) is defined as:

Fourier series of a Square Wave:

Let’s try computing a Fourier series for a square wave signal that is on for half the time in .

The function is shown below:


Program:

clc;
clear all;
close all;
N = 100; %Number of points plotted
x = linspace(-1,1,N);
f = sign(x);
sum = 0.*x;
M = input('Enter the value of M:');% number of coefficients
for n = 1:2:M
sum = sum + (4/(n*pi))*sin(n*pi*x);
end
figure
plot(x,sum,'r','LineWidth',2)
hold on
plot(x,f,'LineWidth',2)
hold on figure
error = abs(sum-f);
plot(x,error,'r','LineWidth',2)

Output:
RESULT: Thus the trigonometric & exponential Fourier series coefficients of a periodic signal are
plotted.

VIVA QUESTIONS:

1. What do you mean by a periodic signal?

2. Define Fourier series by using trigonometric and exponential form for periodic signals.

3. What is Half Wave Symmetry?

4. What are the properties of Continuous-Time Fourier Series?

5. Define the properties of convolution

6. What is the condition for the existence of Fourier series?


Ex. No: 04 Fourier transform of a given signal, Plot its amplitude Date :
and phase spectrum

Aim: To obtain Fourier Transformand InverseFourier Transform of a given Signal/ Sequence and to
plot its Magnitude and Phase Spectra.

Requirements:
PC with MATLAB software –R2023a

Theory:
FourierTransformTheorems:
The Fourier transform as follows. Suppose that ƒ is a function which is zero outside of some
interval [−L/2, L/2]. Then for any T ≥ L we may expand ƒ in a Fourier series on the interval
[−T/2,T/2], where the "amount" of the wave e2πinx/T in the Fourier series of ƒ is given by By
definition Fourier Transform of signal f(t) is defined as

The fast Fourier transform (FFT) is an efficient algorithm for computing the DFT of a sequence; it
is not a separate transform. It is particularly useful in areas such as signal and image processing,
where its uses range from filtering, convolution, and frequency analysis to power spectrum
estimation.
For length N input vector x, the DFT is a length N vector X, with elements N
X(k) = sum x(n)*exp(-j*2*pi*(k-1)*(n-1)/N), 1 <= k <= N. n=1
The inverse DFT (computed by IFFT) is given by N
X(n) = (1/N) sum X(k)*exp( j*2*pi*(k-1)*(n-1)/N), 1 <= n <= N.k=1.
Program:
A.
clc;
clear all;
close all;
syms t s ;
syms w float;
f=3*exp(-t)*heaviside(t); % given function
F=fourier(f); % to find Fourier Transform
disp('the fourier transform of 3*exp(-t)*u(t) =');
disp(F); % to display the result in the command window
w=-2*pi:pi/50:2*pi;
F1=subs(F,w); % substitute w in F function
Fmag=abs(F1); % to find magnitude
Fphas=angle(F1); % to find phase
Fphas=angle(F1); % to find phase
subplot(2,1,1);
plot(w,Fmag);
xlabel('w ---- >');
ylabel('Magnitude --- >');
title('Magnitude spectrum');
grid;
subplot(2,1,2);
plot(w,Fphas);
xlabel('w ---- >');
ylabel('Phase in radians -- >');
title('Phase spectrum');
grid;

(OR)
B.
Clc;
clear all;
close all;
syms t;
x=exp(-2*t)*heaviside(t);
y=fourier(x);
disp('Fourier Transform of input signal'); y
z=ifourier(y);
disp('Inverse Fourier Transform of input signal'); z
mg=abs(y);
subplot(2,1,1);
ezplot(mg);
xlabel('time');
ylabel('amplitude');
title('magnitude spectrum of a input signal');
grid;
pha=atan(imag(y)/real(y));
subplot(2,1,2);
ezplot(pha);
xlabel('time');
ylabel('amplitude');
title('phasespectrum of a input signal');
grid;
Output:
A. The Fourier transform of 3*exp(-t)*u(t) = 3/(w*i + 1)

(OR)

B.

Fourier Transform of input signal Y=1/(2+w*i)

Inverse Fourier Transform of input signal Z=Heaviside(x)/exp(2*x)


Result:
The Fourier Transform of a given signal and plotting its magnitude and phase spectrum
have been demonstrated using MATLAB.

Viva Questions:
1. Define Fourier Series?
2. What are the properties of Continuous-Time Fourier Series?
3. What is the sufficient condition for the existence of F.T?
4. Define the F.T of a signal?
5. What is the difference b/w F.T&F.S?
6. Define Scaling Property of FT?
7. Explain Time Convolution Property of FT?
8. Explain Frequency Convolution Property of FT?
9. Explain the linearity property?
10. Describe the advantages of FT?
Ex.No : 05 Convolve two discrete time sequences and Date:
Plot all the signal
Aim:
To find and plot the convolution of two sequence using MATLAB program.
Requirements:
PC with MATLAB software –R2023a
Theory
It is a mathematical operation on two functions which producing a third function that is typically
viewed as a modified version of one of the original functions, giving the area overlap between the
two functions as a function of the amount that one of the original functions is translated.
Convolution is similar to cross-correlation. It has applications that include probability, statistics,
computer vision, image and signal processing, electrical engineering, and differential equations.
% Program for linear Convolution
a=input ('enter the sequence A = ');
b=input ('enter the sequence B = ');
m=length(a);
n=length (b);
c=conv (a,b);
l=length(c);
disp ('length of Sequence A');
disp (m);
disp ('length of Sequence B');
disp (n);
disp ('length of linear convolution sequence');
disp (l);
disp ('Output of linear convolution'); disp (c);
subplot (1,3,1);
stem (a) ;
xlabel ('samples');
ylabel ('amplitude');
title ('plot of sequence A');
subplot (1,3,2);
stem (b);
xlabel ('samples');
ylabel ('amplitude');
title ('plot of sequence B'); subplot (1,3,3);
stem (c) ;
xlabel ('samples');
ylabel ('amplitude');
title (' linear convolution of A and B ');

Output for Linear Convolution


Enter the sequence A = [2 1 3 2]
Enter the sequence B = [3 2 1 4]

% Program for Circular Convolution


a=input ('Enter the sequence A = ');
b=input ('Enter the sequence B = ');
m=length (a);
n=length (b);
l=max (m,n);
disp ('The length of sequence A'); disp (m);
disp ('The length of sequence B'); disp (n);
disp ('the length of the Circular Convolution'); disp (l);
c=fft (a,l);
d=fft (b,l);
e=c.*d;
f=ifft(e);
disp ('The of circular convolution of A and B'); disp (f);
subplot (1,3,1);
stem (a);
xlabel ('samples');
ylabel ('amplitude');
title ('plot of sequence A'); subplot (1,3,2);
stem (b);
xlabel ('samples');
ylabel ('amplitude');
title ('plot of sequence B');
subplot (1,3,3);
stem (f) ;
xlabel ('samples');
ylabel ('amplitude');
title ('plot of Circular Convolution of A and B');

Output for Circular Convolution


Enter the sequence A = [2 4 2 3]

Enter the sequence B = [3 2 1]


Result: The discrete convolution of two sequences were found using MATLAB program

Viva Questions:
1.Define convolution.
2.What is the difference between linear and circular convolution?
3.State zero appending.
4.Write the formula for length calculation in linear and circular convolution.
5.List the applications of convolution process
Autocorrelation and cross correlation of given
Ex. No: 06 Date:
sequences

Aim: To Write a program to compute Auto Correlation and Cross Correlation between Signals
and Sequences.
Software required:
Requirements:
PC with MATLAB software –R2023a
Theory:
Cross Correlation:
In signal processing, cross-correlation is a measure of similarity of two series as a function of the
lag of one relative to the other. This is also known as a sliding dot product or sliding innerproduct.
It is commonly used for searching a long signal for a shorter, known feature. It has applications in
pattern recognition, single particle analysis, electron tomography, averaging, cryptanalysis, and
neurophysiology.
Auto Correlation:
It is also known as serial correlation or cross-autocorrelation. It is the cross-correlation of a signal
with itself at different points in time (that is what the cross stands for). Informally, it is the
similarity between observations as a function of the time lag between them. It is a mathematical
tool for finding repeating patterns, such as the presence of a periodic signal obscured by noise, or
identifying the missing fundamental frequency in a signal implied by its harmonic frequencies. It is
often used in signal processing for analyzing functions or series of values, such as time domain
signals

Program:
a=input('enter the first sequence = ');
b=input('enter the second sequence = ');
subplot(3,2,1);
stem(a);
xlabel('samples');
ylabel('amplitude');
title('Plot of Sequence A');
subplot(3,2,2);
stem(b);
xlabel('samples');
ylabel('amplitude');
title('Plot of Sequence B');
c=xcorr(a);
subplot(3,2,3);
stem(c);
xlabel('samples');
ylabel('amplitude');
title('Auto Correlation of A');
d=xcorr(b);
subplot(3,2,4);
stem(d);
xlabel('samples');
ylabel('amplitude');
title('Auto Correlation of B');
e=xcorr(a,b);
subplot(3,2,5);
stem(e);
xlabel('samples');
ylabel('amplitude');
title('Cross Correlation of A and B');
f=xcorr(b,a);
subplot(3,2,6);
stem(f);
xlabel('samples');
ylabel('amplitude');
title('Cross Correlation of B and A');
Output:
enter the first sequence = [2 1 3 2]
enter the second sequence = [3 2 1 4]
Result:
Thus, Auto correlation and Cross correlation between signals and sequences is computed using
MATLAB.

VIVA QUESTIONS: -
1. Define Correlation? And its properties?
2. Define Auto-Correlation?
3. Define Cross-Correlation?
4. What is the importance of correlation?
5. What is the difference b/w correlation and convolution?
Linearity and Time Invariance properties of a given
Ex. No: 7 Date :
Continuous System

Aim: To compute linearity and time in-variance properties of a given continuous /discrete system.
Requirements:
PC with MATLAB software –R2023a
Theory:
Linearity Property:
Any system is said to be linear if it satisfies the superposition principal
superposition principal state that Response to a weighted sum of input signal equal to the
corresponding weighted sum of the outputs of the system to each of the individual input signals

X(n)-input signal
Y(n) -output signal
Y(n)=T[x(n)]
Y1(n)=T[X1(n)] : Y2(n)=T[X2(n)]
x3=[a X1(n)] +b [X2(n) ]
Y3(n) = T [x3(n)]
= T [a X1(n)] +b [X2(n) ] = a Y1(n)+ b [X2(n) ]= Z3(n)
Let a [Y1(n)]+ b [X2(n) ] =Z3(n)
If Y3(n )- Z3(n)=0 then the system is stable other wise it is not stable.
Linear Time Invarient Systems (Lti):
A system is called time invariant if its input – output characteristics do not change with time.
X(t)- input : Y(t) -output
X(t-T) -delay input by T seconds : Y(t-T) - Delayed output by T seconds

Program 1:
clc;
clear all;
close all;
n=0:40; a=2; b=1;
x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2;
y=n.*x;
y1=n.*x1;
y2=n.*x2;
yt=a*y1+b*y2;
d=y-yt;
d=round(d)
if d
disp('Given system is not satisfy linearity property');
else
disp('Given system is satisfy linearity property');
end
subplot(3,1,1), stem(n,y); grid
subplot(3,1,2), stem(n,yt); grid
subplot(3,1,3), stem(n,d); grid

Output:
d=0 so the it displays the output is 'Given system is satisfy linearity property'
Program-2
clc;
clear all;
close all;
n=0:40; a=2; b=-3;
x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2;
y=x.^2;
y1=x1.^2;
y2=x2.^2;
yt=a*y1+b*y2;
d=y-yt;
d=round(d);
if d
disp('Given system is not satisfy linearity property');
else
disp('Given system is satisfy linearity property');
end
subplot(3,1,1), stem(n,y); grid
subplot(3,1,2), stem(n,yt); grid
subplot(3,1,3), stem(n,d); grid
output:

The d is not equal to zero, so the output displays ' Given system is not satisfy linearity property'
Program-3:
clc;
close all;
clear all;
n=0:40;
D=10;
x=3*cos(2*pi*0.1*n)-2*cos(2*pi*0.4*n);
xd=[zeros(1,D) x];
y=n.*xd(n+D);
n1=n+D;
yd=n1.*x;
d=y-yd;
if d
disp('Given system is not satisfy time shifting property');
else
disp('Given system is satisfy time shifting property');
end
subplot(3,1,1),stem(y),grid;
subplot(3,1,2),stem(yd),grid;
subplot(3,1,3),stem(d),grid;

Output:
d is not equal to zero so the output displays 'Given system is not satisfy time shifting property'.
Program-4:
clc;
close all;
clear all;
n=0:40;
D=10;
x=3*cos(2*pi*0.1*n)-2*cos(2*pi*0.4*n);
xd=[zeros(1,D) x];
x1=xd(n+D);
y=exp(x1);
n1=n+D;
yd=exp(xd(n1));
d=y-yd;
if d
disp('Given system is not satisfy time shifting property');
else
disp('Given system is satisfy time shifting property');
end
subplot(3,1,1),stem(y),grid;
subplot(3,1,2),stem(yd),grid;
subplot(3,1,3),stem(d),grid;
Output:

d=0 so output displays 'Given system is satisfy time shifting property'.


Result: Hence Linearity and Time in-variance property of given system has been verified Using
MATLAB.
Viva Questions:
1.What are the linearity and time invariance properties of a system?
2.What are the properties of time invariance?
3. What is an example of a linear time-invariant system?
4.What is the formula for time invariance?
5.What is the condition for a time-invariant system?
Generate discrete time sequence by sampling a
continuous time signal. Show that with sampling rates
Ex. No: 08 less than Nyquist rate, aliasing occurs while Date :
reconstructing the signal

Aim:To write a program to generate discrete time sequence by sampling a continuous time signal.
Show that with sampling rates less than Nyquist rate, aliasing occurs while reconstructing the
signal.
Requirements:
PC with MATLAB software –R2023a
Theory:
Sampling:
The signals we use in the real world, such as our voices, are called "analog" signals. To
process these signals in computers, we need to convert the signals to "digital" form. While an
analog signal is continuous in both time and amplitude, a digital signal is discrete in both time
and amplitude. To convert a signal from continuous time to discrete time, a process called
sampling is used. The value of the signal is measured at certain intervals in time. Each
measurement is referred to as a sample.

When the continuous analog signal is sampled at a frequency F, the resulting discrete signal
has more frequency components than did the analog signal. To be precise, the frequency
components of the analog signal are repeated at the sample rate.

How many samples are necessary to ensure we are preserving the information contained in
the signal? If the signal contains high frequency components, we will need to sample at a higher
rate to avoid losing information that is in the signal. In general, to preserve the full information
in the signal, it is necessary to sample at twice the maximum frequency of the signal. This is
known as the Nyquist rate. The Sampling Theorem states that a signal can be exactly
reproduced if it is sampled at a frequency F, where F is greater than twice the maximum
frequency in the signal.

What happens if we sample the signal at a frequency that is lower that the Nyquist rate?
When the signal is converted back into a continuous time signal, it will exhibit a phenomenon
called aliasing. Aliasing is the presence of unwanted components in the reconstructed signal.
These components were not present when the original signal was sampled. In addition, some of
the frequencies in the original signal may be lost in the reconstructed signal. Aliasing occurs
because signal frequencies can overlap if the sampling frequency is too low. Frequencies "fold"
around half the sampling frequency - which is why this frequency is often referred to as the
folding frequency.

Program:
% MATLAB Program to Demonstrate Aliasing
% Parameters
Fs_cont = 1000; % Continuous-time sampling rate (Hz)
T_cont = 1 / Fs_cont; % Continuous-time sampling period (s)
t_cont = 0:T_cont:1; % Time vector for continuous signal
f_signal = 50; % Frequency of the continuous signal (Hz)

x_cont = sin(2 * pi * f_signal * t_cont); % Continuous-time signal

% Sampling Rates
Fs1 = 100; % Sampling rate 1 (Hz) - Below Nyquist rate
Fs2 = 200; % Sampling rate 2 (Hz) - Exactly at Nyquist rate
Fs3 = 400; % Sampling rate 3 (Hz) - Above Nyquist rate

% Time Vectors for Sampling


T1 = 1 / Fs1; % Sampling period for Fs1
T2 = 1 / Fs2; % Sampling period for Fs2
T3 = 1 / Fs3; % Sampling period for Fs3

t1 = 0:T1:1; % Time vector for Fs1


t2 = 0:T2:1; % Time vector for Fs2
t3 = 0:T3:1; % Time vector for Fs3

% Sampled Signals
x1 = sin(2 * pi * f_signal * t1); % Signal sampled at Fs1
x2 = sin(2 * pi * f_signal * t2); % Signal sampled at Fs2
x3 = sin(2 * pi * f_signal * t3); % Signal sampled at Fs3

% Reconstruct Signals
reconstructed1 = zeros(size(t_cont)); % Reconstructed signal for Fs1
reconstructed2 = zeros(size(t_cont)); % Reconstructed signal for Fs2
reconstructed3 = zeros(size(t_cont)); % Reconstructed signal for Fs3

for i = 1: length(t1)
reconstructed1 = reconstructed1 + x1(i) * sinc((t_cont - t1(i)) / T1);
end
for i = 1: length(t2)
reconstructed2 = reconstructed2 + x2(i) * sinc((t_cont - t2(i)) / T2);

end
for i = 1: length(t3)
reconstructed3 = reconstructed3 + x3(i) * sinc((t_cont - t3(i)) / T3);
end

% Plotting
figure;
subplot(3, 2, 1);
plot(t_cont, x_cont);
title('Continuous-Time Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3, 2, 2);
stem(t1, x1, 'r');
title('Signal Sampled at Fs1 (Below Nyquist Rate)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3, 2, 3);
plot(t_cont, reconstructed1, 'b');
title('Reconstructed Signal from Fs1');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3, 2, 4);
stem(t2, x2, 'r');
title('Signal Sampled at Fs2 (Nyquist Rate)');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(3, 2, 5);
plot(t_cont, reconstructed2, 'b');
title('Reconstructed Signal from Fs2');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3, 2, 6);
stem(t3, x3, 'r');
title('Signal Sampled at Fs3 (Above Nyquist Rate)');

xlabel('Time (s)');
ylabel('Amplitude');
subplot(3, 2, 7);
plot(t_cont, reconstructed3, 'b');
title('Reconstructed Signal from Fs3');
xlabel('Time (s)');
ylabel('Amplitude');

% Display the plots


title ('Sampling and Reconstruction of a Continuous-Time Signal');

Output Waveforms:

Viva Questions:

1. What is Sampling?
2. Define Sampling theorem?
3. What is Nyquist Rate?
4. How many types of samplings are their?
5. What is aliasing effect? How to overcome it?
Magnitude and Phase response of first order low pass
Ex .No: 09 and high pass filter Date :

Aim: To find magnitude and phase response of first order low pass and high pass filter. Plot the
responses in logarithmic scale.

Requirements:
PC with MATLAB software –R2023a

Theory:

Filters are fundamental components in signal processing that allow certain frequency components
of a signal to pass through while attenuating others. Depending on their frequency response, filters
can be classified into various types, including low-pass, high-pass, band-pass, and band-stop filters.
In this experiment, we focus on first-order low-pass and high-pass filters.

A first-order low-pass filter allows signals with a frequency lower than a certain cutoff frequency
(fc) to pass through while attenuating signals with frequencies higher than fc. The transfer function
of a first-order low-pass filter is given by:

At the cutoff frequency, the magnitude of the filter's response is -1/√2 (approximately -3 dB) of its
maximum value. This marks the point where the filter starts significantly attenuating higher
frequencies.

A first-order high-pass filter, in contrast, allows signals with a frequency higher than the cutoff
frequency to pass through, while attenuating signals with lower frequencies. The transfer function
of a first-order high-pass filter is given by

At frequencies much higher than the cutoff frequency, the high-pass filter exhibits a flat response,
while it significantly attenuates signals at frequencies lower than fc.

Magnitude Response: The magnitude response of a filter shows how the amplitude of different
frequency components is affected by the filter. It is expressed in decibels (dB) and plotted on a
logarithmic scale to clearly observe the attenuation characteristics across a wide range of
frequencies.
Phase Response: The phase response describes the phase shift introduced by the filter to different
frequency components of the input signal. The phase shift is usually expressed in radians.

Methodology:

 Define the cutoff frequency and sampling frequency.


 Calculate the angular frequency vector for the range of frequencies.
 Compute the transfer function for the low-pass and high-pass filters.
 Calculate the magnitude and phase response of both filters.
 Plot the magnitude response on a logarithmic scale and the phase response.

Code:

Clc ;clear all; close all;

fc = 1000; % Cutoff frequency in Hz % Define the cutoff frequency

fs = 10000; % Sampling frequency in Hz % Sampling frequency

w = 2*pi*(0:fs/2)/fs; % Angular frequency

f = (0:fs/2)*(fs/2)/(fs/2); % Frequency vector for plotting

H_LPF = 1./(1 + 1i*(w/fc)); % Low Pass Filter (LPF) Transfer Function

H_HPF = (1i*(w/fc))./(1 + 1i*(w/fc)); % High Pass Filter (HPF) Transfer Function

% Magnitude Response

mag_LPF = abs(H_LPF);

mag_HPF = abs(H_HPF);

% Phase Response

phase_LPF = angle(H_LPF);

phase_HPF = angle(H_HPF);

% Plotting Magnitude Response on a logarithmic scale

figure;

subplot(2,1,1);

semilogx(f, 20*log10(mag_LPF), 'LineWidth',2);

hold on;

semilogx(f, 20*log10(mag_HPF), 'r', 'LineWidth',2);

title('Magnitude Response of First Order Filters');


xlabel('Frequency (Hz)');

ylabel('Magnitude (dB)');

legend('Low Pass Filter', 'High Pass Filter');

grid on;

% Plotting Phase Response

subplot(2,1,2);

semilogx(f, phase_LPF, 'LineWidth',2);

hold on;

semilogx(f, phase_HPF, 'r', 'LineWidth',2);

title('Phase Response of First Order Filters');

xlabel('Frequency (Hz)');

ylabel('Phase (radians)');

legend('Low Pass Filter', 'High Pass Filter');

grid on;

OUTPUT:
Result: The magnitude and phase response of first order low pass and high pass filter has been
plotted in logarithmic scale.

Viva Questions:

1.What is phase response?

2.What is magnitude response?

3. What is a first order filter?

4.What is logarithmic scale?

5.What is difference between high pass & low pass filters?


Generate Complex Gaussian noise and find its mean,
variance, Probability Density Function and Power
Ex. No: 10 Date :
Spectral Density

Aim: To generate a random data (with bipolar) for a given data rate.

Requirements:
PC with MATLAB software –R2023a

Program:

clc;

clear all;

close all;

tic;

h = randi([0 1],1,10);

toc

disp('The random Binary Sequence is:')

disp(h)

clf;

tic n=1;

l=length(h);

h(l+1)=1;

while n<=length(h)-1;

t=n-1:0.001:n;

if h(n) == 0 if h(n+1)==0

y=-(t<n-0.5)-(t==n);

else end

y=-(t<n-0.5)+(t==n);

d=plot(t,y);grid on
title('Line code BIPOLAR RZ');

set(d,'LineWidth',2.5);

hold on;

axis([0 length(h)-1 -1.5 1.5]); else

if h(n+1)==0

%y=(t>n-1)-2*(t==n);

y=(t<n-0.5)-1*(t==n);

else

%y=(t>n-1)+(t==n-1);

y=(t<n-0.5)+1*(t==n);

end

%y=(t>n-1)+(t==n-1);

d=plot(t,y);

grid on;

title('Line code BIPOLAR RZ');

set(d,'LineWidth',2.5);

hold on;

axis([0 length(h)-1 -1.5 1.5]);

end

n=n+1;

%pause;

end

toc

OUTPUT WAVEFORMS:

Elapsed time is 0.000816 seconds. The random Binary Sequence is:

0100001110

Elapsed time is 1.010915 seconds.


Result: Hence random data with bipolar signal was generated by using MATLAB programming.

VIVA Questions:

1. What is data rate?


2. What is baud rate?
3. What is Line Coding?
4. What is Bipolar Return to Zero and Unipolar Return to Zero Coding?
5. What is Bipolar non-Return Zero and Unipolar Non-Return to Zero Coding?

You might also like