0% found this document useful (0 votes)
19 views22 pages

Experiment - 1: Aim: Software Used: Theory

Uploaded by

nimitbharti235
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)
19 views22 pages

Experiment - 1: Aim: Software Used: Theory

Uploaded by

nimitbharti235
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/ 22

EXPERIMENT – 1

AIM : Intro to MATLAB & its basic commands.

SOFTWARE USED : MATLAB.

THEORY :-

● MATLAB is used for machine learning, signal processing image processing, computer
vision,communucations,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 system.
● MATLAB allow matrix manipulations, plotting of function and data,implementation of algorithms,creation of
user interfaces, and interfacing with programs written in other language.

PRIMARY COMMANDS:-

● Help lists all primary help topics in the command window. Each main help topic correspods to a folder name
on the MATLAB search path.
● Help name displays the help text for the functionality specified nby name,such as a function , method, class,
toolbox or variable.
● Plot draw a plot,see also figure, axis , subplot.
● Print print the current plot window up into pieces,see also plot,figure.
● xlable/ylable add a label to the horizontal/vertical axis of the current plot,see also title,text,gtext. PROS. &
CONS.:-
PROS. CONS.
MATLAB contain a lot of advance toolboxes such as There is not as much open source code available
signal processing, wavelet,etc.Find analogous because MATLAB requires a license.
funtionality in other language is possible but difficult.
Good documentation. You cannot integrate your code into a web service.
Good customer support. MATLAB is expensive.

OUTPUT:-

Akash 04396202822
RESULT:- The study of MATLAB and the various commands used in MATLAB is complete.

VIVA:-

1. What is MATLAB & where it is used?

MATLAB(matrix laboratory) is a multiparadigm numeriacal computing enviroment and fourth generation

language. MATLAB users come from various background of engineering , science,and economics.

2. How to start and quit MATLAB?

START Select MATLAB icon.ON Microsoft window platform ,double-click,the MATLAB icon.

QUIT Click the close box in the MATLAB desktop.

Click on the left side of the desktop title bar and select close.

Type quit or exit at the command prompt.

Akash 04396202822
3. What are the various desktop tools and window used in MATLAB.

Start button and launch pad – Run tools and access documentation for all of your MathWorks products. Commoand
window—Run MATLAB functions.

Command history – View a log of the function you entered in the command window,copy them and execute

them.

Help browser – View and search the documentation for MATLAB.

Current directory browser – view MATALB files and related files,perform file operation such as open , and find
content.

Workspace browser – View and make changes to the. contents of the workspace.

4. Explain 10-15 basic commands used in MATLAB.

MATLAB is an interactive program for numerical computation and data visualization . You can enter a command by
typing it at the MATLAB prompt’>>’ on the Command window.

1.Commands for Managing a Session


COMMAND PURPOSE
clc Clear command window

Akash 04396202822
clear Removes variables from memory
exist Check for existence of file or variale.
global Declares variables to be global.
help Searches for a help topic.

2.Commands for working with the system.


COMMAND PURPOSE
cd Change current directory
date Display current data
delete Deletes a file
diary Switches on/off diary file recording.

3.input and output commands


COMMAND PURPOSE
disp Displays contents of an array or string
fscanf Read formatted data from a file.
format Controls screen-display format
fprintf Perform formatted writes to screen or file.
input Display prompts and waits for input.

4. Vector,matrix and Array Commands


COMMAND PURPOSE
cat Conatenates arrays.
find Finds indices of nonzero element.
length Computes number of element.
linespace Creates regularly spaced vector.

5.Plotting commands
print Prints plot or saves plot to a file.
title Puts text at top of plot.
xlabel Adds text label to x-axis.
ylable Adds text label to y-axis.
axes Creates axes objects.
close Closes the current plot

Akash 04396202822
EXPERIMENT-2
AIM:- To plot unit step, unit impulse, ramp,exponatial functions & sinusoidal signals.

SOFTWARE USED:- MATLAB.

PROGRAM:-

% generation of sine wave t=0:0.01:pi;

X=sin(2*pi*t);

Subplot(3,2,1);

Plot(t,x); title(‘sine

wave’);

xlable(‘time’);

Ylabel(‘amplitude’); %Generation

of cosine wave

t=0:0.01:pi;

Y=cos(2*pi*t);

Subplot(3,2,2);

Plot(t,y);

Title(‘cosine wave’); xlabel(‘time’);

ylabel(‘amplitude’);

%Generation of ramp wave

n=0,N-1; r=n;

Subplot(3,2,3); stem(n,r);

title(‘Ramp signal’);

xlabel(‘time’);

ylabel(‘amplitude’);

%Generation of Exponantial wave

N=input(‘enter the value of N’);

n=0:N-1; a=input(‘enter the value

Akash 04396202822
of a’); e=exp(a*n); subplot(3,2,4);

stem(n,e); title(‘Exponantial

signal’); xlabel(‘time’);

ylabel(‘amplitude’); %Generation

of unit step function s=ones(1,N);

subplot(3,2,5); stem(n,s);

title(‘unit steo function’);

xlabel(‘time’); ylabel(‘amplitude’);

%Generation of unit impulse

ni=-2:1:2; I=[zeros(1,2) ones(1,1)

zeros(1,2)]; subplot(3,2,6);

stem(ni,I); title(‘unit impulse

function’); xlabel(‘time’);

ylabel(‘amplitude’);

Akash 04396202822
OUTPUT:-

RESULT:-

Plotting of unit step,unit impulse,ramp,exponantial function and sinusoidal signal using MATLAB software is
complete.

Akash 04396202822
EXPERIMENT-3
AIM:- To plot convolution of two linear function.

SOFTWARE USED:- MATLAB.

THEORY:- Convolution of two function mathematically is given by:-

PROGRAM:-

clc; clear

all; close

all;

%defination 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’);

%Defination 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 sequence’); xlabel(‘time’);

ylabel(‘amplitude’);

%Convolution of x & h

Akash 04396202822
nyl=nx(1) + nh(1);

nyr=nx(length(x)) + nh(lenght(h));

ny=nyl:nyr; y=conv(x,h);

subplot(3,1,3); stem(ny,y);grid

on; title(‘output sequence’);

xlable(‘time’);

ylabel(‘amplitude’);

OUTPUT:-

RESULT:- Study of convolution of two function using MATLAB is finished successfully.

Akash 04396202822
EXPERIMENT-4
AIM: To plot auto correlation of two sequences.

SOFTWARE USED:- MATLAB R2012a

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 analysing 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=input('Enter the value of x '); nx=0:1;

subplot(4,1,1);

stem(nx,x); grid on

Akash 04396202822
xlabel('Time');

ylabel('Amplitude');

title('Definition of x '); % definition of h

h=input('Enter the value of h '); nh=0:2;

subplot(4,1,2); stem(nh,h); grid on

xlabel('Time'); ylabel('Amplitude');

title('Definition of h '); % Autocorreletion

of x & x

x1=fliplr(x); n

* 1 = - 1/0 ;

nylac=nx(1)+nx1(1); nyrac=nx(length(x))+nx1(length(x1));

yac=conv(x,x1); nyac=nylac:nyrac; subplot(4,1,3);

stem(nyac, yac); grid on xlabel('Time');

ylabel('Amplitude'); title('Auto correletion'); %

Crosscorreletion of x & h h1=fliplr(h); nh1=-2:0;

nylcc=nx(1)+nh1(1);

nyrcc=nx(length(x))+nh1(length(h1)); ycc=conv(x,h1);

nycc=nylcc:nyrcc; subplot(4,1,4); stem(nycc, ycc);

grid on xlabel('Time'); ylabel('Amplitude'); title('Cross

correletion');

Akash 04396202822
OUTPUT:-

Akash 04396202822
EXPERIMENT-5
AIM:-To plot the magnitude and phase plot spectrum of signal using fourier series.
SOFTWARE USED:- R2017a

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,

● To plot the magnitude spectrum calculate (R2+I2)½ and


● To plot the phase spectrum, calculate tan-1 (I/R) Where,’R’ is the real part and ‘I’ is the Imaginary part.

The function abs (|Cn|) return the magnitude and anlge (<Cn) Vs n.

CODE/PROGRAM:-

clc; clear all;

close all; syms

t; T = pi w=2 *

pi / T; xt =

exp(- t / 2); n =

- 4:4;

Cn=1/T * int(xt * exp (-1j * w * n * t),t,0,T);

Cn = double(Cn) magnitudeCn = abs(Cn)

%magnitude

angleCn = angle(Cn) %angle subplot

(2, 1, 1)

Stem(n,magnitudeCn);

Grid on;

Xlabel(‘n’);

Ylable(‘|Cn|’);

Title(‘magnitude plot’);

Akash 04396202822
Subplot(2,1,2);

Stem(n,angleCn);

Grid on;

Xlable(‘n’);

Ylabel(‘<Cn’);

Title(‘phase plot’);

OUTPUT:-

RESULT:- The magnitude and phase plot spectrum of signal are plotted using Fourier series.

Akash 04396202822
EXPERIMENT-6
AIM:- To plot the magnitude and phase plot spectra of signal using Fourier Transforms.

SOFTWARE USED:- R2017a.

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:

For any real number. CODE/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;

Akash 04396202822
OUTPUT:-

RESULT:-

The magnitude and phase plot spectra of signal are plotted using Fourier Transform.

Akash 04396202822
EXPERIMENT-7
AIM:- Determine and plot discrete time fourier time transform of the following:-

(A) Rectangular function (B) sinusoidal function

SOFTWARE USED:- MATLAB (R2017a).

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.

DTFT=

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));

Akash 04396202822
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');

Akash 04396202822
GRAPH:-

Akash 04396202822
EXPERIMENT-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 R2017a

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(4,1,1); plot(t,xt); title('cos

function'); xlabel('time---->');

Akash 04396202822
ylabel('amplitude------->');

%program sampling at (A)(fs < 2fm)

fs1=1.3* fm ; n1 = 0:1 / fs1:1;

xn1=cos(2 * pi* fm * n1) ;

subplot(4,1,2);

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(4,1,3); plot(t,xt,'r',

n2,xn2,'b'); 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(4,1,4);

plot(t,xt,'r',n3,xn3,'b');

title('oversampling'); xlabel

(‘time------->’) ; ylabel('amplitude------

>');

Akash 04396202822
GRAPH:-

OUTPUT:-

Akash 04396202822

You might also like