0% found this document useful (0 votes)
52 views27 pages

Satyam Singh (SNS Lab File)

The document describes 7 experiments conducted in MATLAB to study various signal processing concepts: 1. The basics of MATLAB including primary commands are explored. 2. Common signals like sine, cosine, ramp, exponential and unit step/impulse are plotted. 3. Convolution of two functions is plotted. 4. Auto correlation and cross correlation of sequences are studied. 5. Fourier series is used to plot the magnitude and phase spectra of a signal. 6. Fourier transforms are used to plot the magnitude and phase spectra. 7. The discrete time Fourier transform of rectangular and sinusoidal signals are determined and plotted.

Uploaded by

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

Satyam Singh (SNS Lab File)

The document describes 7 experiments conducted in MATLAB to study various signal processing concepts: 1. The basics of MATLAB including primary commands are explored. 2. Common signals like sine, cosine, ramp, exponential and unit step/impulse are plotted. 3. Convolution of two functions is plotted. 4. Auto correlation and cross correlation of sequences are studied. 5. Fourier series is used to plot the magnitude and phase spectra of a signal. 6. Fourier transforms are used to plot the magnitude and phase spectra. 7. The discrete time Fourier transform of rectangular and sinusoidal signals are determined and plotted.

Uploaded by

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

Experiment No.

– 1

Aim: Intro to MATLAB & its basic commands.


Software Used: MATLAB
Theory:
MATLAB is used for machine learning, signal
processing, image processing, computer vision,
communications, computational finance, control
design, robotics, and much more.
MATLAB platform is optimized for solving
engineering and scientific problems. The matrix-
based MATLAB language is the world’s most
natural way to express computational
mathematics.
MATLAB code can be integrated with other
languages, enabling you to deploy algorithms
and applications within web, enterprise, and
production systems.
MATLAB allows matrix manipulations, plotting
of functions and data, implementation
of algorithms, creation of user interfaces, and
interfacing with programs written in other
languages.
Primary Commands:
Help: lists all primary help topics in the
Command Window. Each main help topic
corresponds to a folder name on the MATLAB
search path.
Help name: displays the help text for the
functionality specified by name, such as a
function, method, class, toolbox or variable.
Plot: Draw a plot, see also figure, axis, subplot.
Print: Print the current plot (to a printer or
postscript file)
Subplot : Divide the plot window up into pieces,
see also plot, figure.
xlabel/ylabel: Add a label to the
horizontal/vertical axis of the current plot, see
also title, text, gtext
Output:
Result:
The study of MATLAB and the various commands is
complete.
Experiment No. – 2

Aim: To plot unit step, unit impulse, ramp,exponential


functions & sinusoidal signals.
Software Used: MATLAB
Program:
%Generation of sine wave
t=0:0.01:5;
x=sin(2*pi*t);
subplot(3,2,1);
plot(t,x);
title('sine wave');
xlabel('time');
ylabel('amplitude');
%Generation of cos wave
t=0:0.01:5;
x=cos(2*pi*t);
subplot(3,2,2);
plot(t,x);
title('cos wave');
xlabel('time');
ylabel('amplitude');
%Generation of Ramp wave
N=input('Enter the value of N');
n=0:N-1;
r=n;
subplot(3,2,3);
stem(n,r);
title('ramp signal');
xlabel('time');
ylabel('amplitude');
%Generation of Exponential wave
N=input('Enter the value of N');
n=0:N-1;
a=input('Enter the value of a');
xn=a.^n;
stem(n,xn);
title('exponential signal');
xlabel('time');
ylabel('amplitude');
%Generation of unit step function
N=input('Enter the value of N');
n=0:N-1;
s=ones(1,N);
subplot(3,2,5);
stem(n,s);
title('unit step function');
xlabel('time');
ylabel('amplitude');
%Generation of unit impulse
n=-6:6;
i=[zeros(1,6) 1 zeros(1,6)];
stem(n,i);
subplot(3,2,6);
stem(n,i);
title('unit impulse function');
xlabel('time');
ylabel('amplitude');
Output:

Result:
Plotting of unit step, unit impulse, ramp ,
exponential functions and sinusoidal signals using
MATLAB software is completed.
Experiment No. – 3

Aim: To plot Convolution of two functions.


Software Used: MATLAB
Theory:
Convolution of two functions mathematically is given
by: -

f(t)=x(t)*h(t)= ∫−∞ 𝑥 (𝜏)ℎ(𝑡 − 𝜏)𝑑𝜏
Program:
clear all;
close all;
%Definition of i/p sequence
x=input('Enter the value of x');
nx=0:1;
subplot(3,1,1);
stem(nx,x);
grid on;
title('Input Sequence');
xlabel('Time');
ylabel('Amplitude');
%Definition of impulse sequence h
h=input('Enter the value of h');
nh=0:2; subplot(3,1,2);
stem(nh,h);
grid on;
title('Input impulse seq.');
xlabel('Time');
8ylabel('Amplitude');
%Convolution of x & h
nyl=nx(1)+nh(1);
nyr=nx(length(x))+nh(length(h));
ny=nyl:nyr;
y=conv(x,h) subplot(3,1,3);
stem(ny,y);grid on;
t title('output Sequence');
xlabel('Time');
ylabel('Amplitude');
Output:

Result:
Study of convolution of two functions using MATLAB is
finished successfully.
Experiment No. – 4

Aim: To plot auto correlation and cross correlation of


two sequences.
Software Used: MATLAB
Theory:
Cross Correlation: In signal processing, cross-correlation is a
measure of similarity of two series as a function of the displacement
of one relative to the other. This is also known as a sliding dot
product or sliding inner-product. 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: Autocorrelation, also known as serial


correlation, is the correlation of a signal with a delayed copy of itself
as a function of delay. Informally, it is the similarity between
observations as a function of the time lag between them. The
analysis of autocorrelation 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.
Unit root processes, trend stationary processes, autoregressive
processes, and moving average processes are specific forms of
processes with autocorrelation.

Program:
clear all ;
close all ;
clc;
%definition of x
x=[1 2 3 4];
subplot(4,1,1);
stem(x);
xlabel('time');
ylabel('amplitude');
title('Definition of x');
%definition of h
h=[4 3 2 1];
subplot(4,1,2);
stem(h);
title('Definition of h');
xlabel('time');
ylabel('amplitude');
%autocorrelation of x&x
y=xcorr(x,x);
subplot(4,1,3);
stem(y);
title('Autocorrelation');
xlabel('time');
ylabel('amplitude');
%crosscorrelation of x&h
y=xcorr(x,h);
subplot(4,1,4);
stem(y);
title('Crosscorrelation');
xlabel('time');
ylabel('amplitude');
Output:

Result:
Study of auto correlation and cross correlation of two
sequences using MATLAB is finished successfully.
Experiment No. – 5
Aim: To plot the magnitude and phase plot spectrum
of signal using Fourier Series .

Software Used: MATLAB

Theory:

Fourier series: is just a means to represent a periodic signal as an


infinite sum of sine wave components. A periodic signal is just a signal
that repeats its pattern at some period. The primary reason that we
use Fourier series is that we can better analyze a signal in another
domain rather in the original domain.
Fourier Series expansion is given below,

𝑇
Cn = 1/T ∫0 𝑥 (𝑡)𝑒 −𝑗𝑛𝑤𝑡 dt

• To plot the Magnitude spectrum calculate √𝑅 2 + 𝐼2 and


𝐼
• To plot the phase spectrum, calculate tan−1 ( ) 𝑅
where, R is the Real part and I is the Imaginary part.

The function abs (|Cn|) returns the magnitude and angle (<Cn) returns
the phase angle in radians.
Magnitude Response is |Cn| vs. n and phase plot is <Cn vs. n.

Program:
clc;
clear all;
close all;
syms t;
T = pi;
w = 2*pi/T;
xt = exp(-t/2);
n = -6:6;
Cn = 1/T*int(xt*exp(-1j*w*n*t),t,0,T);
Cn = double(Cn
%magnitude
magnitudeCn = abs(Cn)
%angle
angleCn = angle(Cn)
subplot(2,1,1);
stem(n,magnitudeCn);
grid on
xlabel('n');
ylabel('|Cn|');
title('Magnitude Plot');
subplot(2,1,2);
stem(n,angleCn);
grid on
xlabel('n');
ylabel'<Cn');
title('Phase Plot');
Output:

Result: The magnitude and phase plot spectrum of


signals are plotted using Fourier Series .
Experiment No. – 6
Aim: To plot the magnitude and phase plot spectra of
signal using Fourier Transforms.

Software Used: MATLAB

Theory:
A function derived from a given function and representing it by a
series of sinusoidal functions. The Fourier Transform decomposes any
function into a sum of sinusoidal basis functions. Each of these basis
functions is a complex exponential of a different frequency.
The following definition:

F(s) = ∫−∞ 𝑓(𝑥)𝑒 −2ð𝑗𝑥𝑠 𝑑𝑥
for any real number .

Program :
clc;
clear all;
close all;
syms t omega;
xt = 2;
expw = exp (-j*omega*t) ;
xjw = int (xt*expw,omega,-2,2) ;
xjw = simplify (xjw) ;
figure (1) ;
subplot (2,1,1) ;
ezplot ('2',[-2 2]) ;
grid on
subplot (2,1,2) ;
ezplot(xjw); grid on

Output:

Result: The magnitude and phase plot spectra of


signals are plotted using Fourier Transform.
Experiment No. – 7

Aim: Determine and plot discrete time Fourier time


transform of the following: - (A) Rectangular function
(B) Sinusoidal function

Software Used: MATLAB


Theory:
In mathematics, the discrete-time Fourier transform (DTFT) is a form
of Fourier analysis that is applicable to the uniformly spaced samples
of a continuous function. The term discrete time refers to the fact
that the transform operates on discrete data (samples) whose
interval often has units of time. From only the samples, it produces a
function of frequency that is a periodic summation of the continuous
Fourier transform of the original continuous function. Under certain
theoretical conditions, described by the sampling theorem, the
original continuous function can be recovered perfectly from the
DTFT and thus from the original discrete samples. The DTFT itself is a
continuous function of frequency, but discrete samples of it can be
readily calculated via the discrete Fourier transform (DFT) (see
Sampling the DTFT), which is by far the most common method of
modern Fourier analysis.
Program: -

clc;
clear all;
close all;
n1=-2:2;
xn1=ones(1,5);
%rectangular function
k=-400:400; w=(pi/100)*k;
Xw=xn1*(exp(-
1*j*pi/100).^(n1'*k));
magXw1=abs(Xw);
subplot(2,2,1);
stem(-8:8,[zeros(1,6) xn1
zeros(1,6)]);
xlabel('n');
ylabel('x');
title('rectangular signal');
subplot(2,2,3);
plot(w/pi,magXw1);
xlabel('frequency in pi units');
ylabel('magnitude');
title('DTFT');
n2=0:100;
xn2=cos(pi*n2/4);
%sinusoidal signal
Xw2=xn2*(exp(-
1*j*pi/100).^(n2'*k));
magXw2=abs(Xw2);
subplot(2,2,2);
stem(n2,xn2);
axis([0 100 -1.5 1.5]);
xlabel('n');
ylabel('xn');
title('sinusoidal signal');
subplot(2,2,4);
plot(w/pi,magXw2);
xlabel('frequency in pi units');
ylabel('magnitude');
title('DTFT');
Output:

Result: Rectangular and Sinusoidal functions of


discrete time are plotted using Fourier time transform.
Experiment No. – 8

Aim: Write a program of sampling at:


A) Less than Nyquist rate (fs<2fm)
B) Nyquist rate (fs = 2fm)
C) Above Nyquist rate (fs>2fm)

Software Used: MATLAB


Theory:
The Nyquist Theorem, also known as the sampling theorem, is a
principle that engineers follow in the digitization of analog signals.
For analog-to-digital conversion (ADC) to result in a faithful
reproduction of the signal, slices, called samples, of the analog
waveform must be taken frequently. The number of samples per
second is called the sampling rate or sampling frequency.

Any analog signal consists of components at various frequencies. The


simplest case is the sine wave, in which all the signal energy is
concentrated at one frequency. In practice, analog signals usually
have complex waveforms, with components at many frequencies.
The highest frequency component in an analog signal determines the
bandwidth of that signal. The higher the frequency, the greater the
bandwidth, if all other factors are held constant.

Suppose the highest frequency component, in hertz, for a given


analog signal is fmax. According to the Nyquist Theorem, the
sampling rate must be at least 2fmax, or twice the highest analog
frequency component. The sampling in an analog to digital converter
is actuated by a pulse generator (clock). If the sampling rate is less
than 2fmax, some of the highest frequency components in the
analog input signal will not be correctly represented in the digitized
output. When such a digital signal is converted back to analog form
by a digital-to-analog converter, false frequency components appear
that were not in the original analog signal. This undesirable condition
is a form of distortion called aliasing.

Program:
%sampling
theorem
clc; close all;
clear all;
t=0:0.01:1;
fm=input('enter frequency
fm');
xt=cos(2*pi*fm*t);
subplot(411); plot(t,xt);
title('cos function');
xlabel('time--->');
ylabel('amplitude--->');

%program sampling at
(A)(fs<2fm)
fs1=1.3*fm;
n1=0:1/fs1:1;
xn1=cos(2*pi*fm*n1);
subplot(412);
plot(t,xt,'r',n1,xn1,'b');
title('undersmapling');
xlabel('time--->.');
ylabel('amplitude--->');

%program sampling at
(B)(fs=2fm)
fs2=2*fm;
n2=0:1/fs2:1;
xn2=cos(2*pi*fm*n2);
subplot(413);
plot(t,xt,'r',n2,xn2,'b');0
title('nyquist rate');
xlabel('time--->');
ylabel('amplitude--->');

%program sampling
at(C)fs<2fm
fs3=2.9*fm;
n3=0:1/fs3:1;
xn3=cos(2*pi*fm*n3);
subplot(414);
plot(t,xt,'r',n3,xn3,'b');
title('oversampling');
xlabel('time--->');
ylabel('amplitude--->');
Output:

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