Você está na página 1de 15

Index

S. No.

Experiment

Date

Signature

EXPERIMENT- 1

Aim- Introduction to MATLAB


TheoryIntroduction to MATLAB
Matlab is an interpreted language for numerical computation. It allows one to perform numerical
calculations, and visualize the results without the need for complicated and time consuming
programming. Matlab allows its users to accurately solve problems, produce graphics easily and
produce code effeciently.
MATLAB programs are stored as plain text in files having names that end with the extension
``.m''. These files are called m-files. MATLAB functions have two parameter lists, one for input
and one for output. One nifty difference between MATLAB and traditional high level languages
is that MATLAB functions can be used interactively. In addition to providing the obvious
support for interactive calculation, it also is a very convenient way to debug functions that are
part of a bigger project.
WindowsCommand window- The window where we type commands and non-graphic output is
displayed. A >> prompt shows the system is ready for input. The lower left hand corner of
the main window also displays Ready or Busy when the system is waiting or calculating.
Previous commands can be accessed using the up arrow to save typing and reduce errors. Typing
a few characters restricts this function to commands beginning with those characters.
Figure window- MATLAB directs graphics output to a window that is separate from the
Command Window. In MATLAB, this window is referred to as a figure. Graphics functions
automatically create new figure windows if none currently exist. If a figure window already
exists, MATLAB uses that window. If multiple figure windows exist, one is designated as the
current figure and is used by MATLAB.
Editor window- The window where we edit m-files the files that hold scripts and functions
that weve defined or are editing. Multiple files are generally opened as tabs in the same editor
window, but they can also be tiled for side by side comparison. Orange warnings and red errors
appear as underlining and as bars in the margin. Hovering over them provides more information;
clicking on the bar takes we to the relevant bit of text. Also MATLAB runs the last saved
version of a file, so we have to save before any changes take effect.

CommandsClc- clears command window


Clear all- Deletes all variables from current workspace
Close all- Closes all open figure windows
For (loop)- Iterates over procedure incrementing i by 1
Subplot- Divide the plot window up into pieces
Stem- Plot discrete sequence data
Plot plot(x,y)- plot the elements of vector y (on the vertical axis of a figure) versus the
elements of the vector x (on the horizontal axis of the figure)
plot(w,abs(y))- plot the magnitude of vector y (on the vertical axis of a figure) versus the
elements of the vector w (on the horizontal axis of the figure)
plot(w,angle(y))- plot the phase of vector y in radian (on the vertical axis of a figure)
versus the elements of the vector w (on the horizontal axis of the figure)
Label Xlabel- Add a label to the horizontal axis of the current plot
Ylabel- Add a label to the vertical axis of the current plot
Title- Add a title to the current plot
Conv- Convolution and polynomial multiplication
Figure- Create a new figure or redefine the current figure

EXPERIMENT- 2
Aim- To generate pseudo random noise signal using Matlab.
Software used- MATLAB
TheoryIn cryptography, pseudo random noise (PRN) is a signal similar to noise which satisfies one or
more of the standard tests for statistical randomness.
Although it seems to lack any definite pattern, pseudo random noise consists of a deterministic
sequence of pulses that will repeat itself after its period.
In cryptographic devices, the pseudo random noise pattern is determined by a key and the
repetition period can be very long, even millions of digits.
Pseudo random noise is used in some electronic musical instruments, either by itself or as an
input to subtractive synthesis, and in many white noise machines.
In spread-spectrum systems, the receiver correlates a locally generated signal with the received
signal. Such spread-spectrum systems require a set of one or more "codes" or "sequences" such
that

Like random noise, the local sequence has a very low correlation with any other sequence
in the set, or with the same sequence at a significantly different time offset, or with
narrow band interference, or with thermal noise.
Unlike random noise, it must be easy to generate exactly the same sequence at both the
transmitter and the receiver, so the receiver's locally generated sequence has a very high
correlation with the transmitted sequence.

Programclc;
clear all;
close all;
N=200; % Define Number of samples
R1=2*(round(rand(1,N))-0.5); % Generate Normal Random Numbers
plot(R1); % Plot of R1
title('Random Signal');
xlabel('Sample Number ---------->');
ylabel('Amplitude ---------->');
axis([0 N -1.5 1.5]);

OutputRandom Signal

1.5

Amplitude ---------->

0.5

-0.5

-1

-1.5

20

40

60

80
100
120
140
Sample Number ---------->

160

180

200

EXPERIMENT- 3
Aim- To find probability density function of a random variable.
Software used- MATLAB
TheoryIn probability theory, a probability density function (pdf), or density of a continuous random
variable, is a function that describes the relative likelihood for this random variable to take on a
given value. The probability of the random variable falling within a particular range of values is
given by the integral of this variables density over that rangethat is, it is given by the area
under the density function but above the horizontal axis and between the lowest and greatest
values of the range. The probability density function is nonnegative everywhere, and its integral
over the entire space is equal to one.
The terms "probability distribution function" and "probability function" have also sometimes
been used to denote the probability density function. However, this use is not standard among
probabilists and statisticians. In other sources, "probability distribution function" may be used
when the probability distribution is defined as a function over general sets of values, or it may
refer to the cumulative distribution function, or it may be a probability mass function rather than
the density. Further confusion of terminology exists because density function has also been used
for what is here called the "probability mass function".

Programclc;
close all;
clear all;
u=1;
sigma=3;
x = -10:0.1:10;
p = exp(-(x-u).*(x-u)/(2*sigma^2))/(sqrt(2*pi)*sigma);
plot(p);
title('PDF Curve');
xlabel('X
---------->');
ylabel('P(x)
---------->');

OutputPDF Curve

0.14
0.12

P(x)

---------->

0.1
0.08
0.06
0.04
0.02
0

50

100
150
X ---------->

200

250

EXPERIMENT- 4
Aim- To find fast fourier transform of a given sequence.
Software used- MATLAB
TheoryA fast Fourier transform (FFT) is an algorithm to compute the discrete Fourier transform (DFT)
and its inverse. A Fourier transform converts time (or space) to frequency and vice versa; an FFT
rapidly computes such transformations. As a result, fast Fourier transforms are widely used for
many applications in engineering, science, and mathematics. The basic ideas were popularized in
1965, but some FFTs had been previously known as early as 1805. Fast Fourier transforms have
been described as "the most important numerical algorithm[s] of our lifetime".[1]
There are many different FFT algorithms involving a wide range of mathematics, from simple
complex-number arithmetic to group theory and number theory; this article gives an overview of
the available techniques and some of their general properties, while the specific algorithms are
described in subsidiary articles linked below.
The DFT is obtained by decomposing a sequence of values into components of different
frequencies. This operation is useful in many fields (see discrete Fourier transform for properties
and applications of the transform) but computing it directly from the definition is often too slow
to be practical. An FFT is a way to compute the same result more quickly: computing the DFT of
N points in the naive way, using the definition, takes O(N2) arithmetical operations, while a FFT
can compute the same DFT in only O(N log N) operations. The difference in speed can be
enormous, especially for long data sets where N may be in the thousands or millions. In practice,
the computation time can be reduced by several orders of magnitude in such cases, and the
improvement is roughly proportional to N / log(N). This huge improvement made the calculation
of the DFT practical; FFTs are of great importance to a wide variety of applications, from digital
signal processing and solving partial differential equations to algorithms for quick multiplication
of large integers.

Programclc;
clear all;
close all;
x = [1 3 8 4 5 6 7]
N = length(x);
for k = 1:N
y(k) = 0;

for n = 1:N
y(k) = y(k)+x(n)*exp(-1i*2*pi*(k-1)*(n-1)/N)
end
end
subplot(2,1,1);
stem(x);
ylabel('Amplitude ---->');
xlabel('n ---->');
title('Input Sequence');
subplot(2,1,2);
stem(y);
ylabel('Amplitude ---->');
xlabel('K ---->');
title('FFT Sequence');

OutputInput Sequence

Amplitude ---->

8
6
4
2
0

4
n ---->
FFT Sequence

4
K ---->

Amplitude ---->

-5

EXPERIMENT- 5
Aim- To find inverse fast fourier transform of a given sequence.
Software used- MATLAB
TheoryA fast Fourier transform (FFT) is an algorithm to compute the discrete Fourier transform (DFT)
and its inverse. A Fourier transform converts time (or space) to frequency and vice versa; an FFT
rapidly computes such transformations. As a result, fast Fourier transforms are widely used for
many applications in engineering, science, and mathematics. The basic ideas were popularized in
1965, but some FFTs had been previously known as early as 1805. Fast Fourier transforms have
been described as "the most important numerical algorithm[s] of our lifetime".[1]
There are many different FFT algorithms involving a wide range of mathematics, from simple
complex-number arithmetic to group theory and number theory; this article gives an overview of
the available techniques and some of their general properties, while the specific algorithms are
described in subsidiary articles linked below.
The DFT is obtained by decomposing a sequence of values into components of different
frequencies. This operation is useful in many fields (see discrete Fourier transform for properties
and applications of the transform) but computing it directly from the definition is often too slow
to be practical. An FFT is a way to compute the same result more quickly: computing the DFT of
N points in the naive way, using the definition, takes O(N2) arithmetical operations, while a FFT
can compute the same DFT in only O(N log N) operations. The difference in speed can be
enormous, especially for long data sets where N may be in the thousands or millions. In practice,
the computation time can be reduced by several orders of magnitude in such cases, and the
improvement is roughly proportional to N / log(N). This huge improvement made the calculation
of the DFT practical; FFTs are of great importance to a wide variety of applications, from digital
signal processing and solving partial differential equations to algorithms for quick multiplication
of large integers.

Programclc;
clear all;
close all;
x = [1 2 5 4 3 2 4]
N = length(x);
for n = 1:N
y(n) = 0;

for k = 1:N
y(n) = y(n)+(1/N)*x(k)*exp(1i*2*pi*(k-1)*(n-1)/N);
end
end
subplot(2,1,1);
stem(x);
ylabel('Amplitude ---->');
xlabel('K ---->');
title('Input Sequence');
subplot(2,1,2);
stem(y);
ylabel('Amplitude ---->');
xlabel('n ---->');
title('IFFT Sequence');

OutputInput Sequence

Amplitude ---->

6
4
2
0

4
K ---->
IFFT Sequence

4
n ---->

Amplitude ---->

1
0.5
0
-0.5
-1

EXPERIMENT- 6
Aim- To perform auto- correlation of a given sequence.
Software used- MATLAB
TheoryAutocorrelation is the cross-correlation of a signal with itself. 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.

One application of autocorrelation is the measurement of optical spectra and the


measurement of very-short-duration light pulses produced by lasers, both using
optical autocorrelators.

The small-angle X-ray scattering intensity of a nanostructured system is the Fourier


transform of the spatial autocorrelation function of the electron density.

In optics, normalized autocorrelations and cross-correlations give the degree of


coherence of an electromagnetic field.

In signal processing, autocorrelation can give information about repeating events like
musical beats (for example, to determine tempo) or pulsar frequencies, though it
cannot tell the position in time of the beat. It can also be used to estimate the pitch of
a musical tone.

In music recording, autocorrelation is used as a pitch detection algorithm prior to


vocal processing, as a distortion effect or to eliminate undesired mistakes and
inaccuracies.[8]

Autocorrelation in space rather than time, via the Patterson function, is used by X-ray
diffractionists to help recover the "Fourier phase information" on atom positions not
available through diffraction alone.

Programclc;
clear all;
x = [1 5 6 3 2 7 3];
N = length(x);
a = x;
y = x;

z = x;
for i = 1:N-1
for i = N-1:-1:1
x(i+1) = x(i);
end
x(1) = 0;
z = [x;z;x];
end
k = z*y';
m = k';
subplot(2,1,1);
stem(a);
title('Input Sequence');
ylabel('Amplitude---->');
xlabel('n---->');
subplot(2,1,2);
stem(m);
title('Autocorrelation Sequence');
ylabel('Amplitude---->');
xlabel('n---->');

OutputInput Sequence

Amplitude---->

8
6
4
2
0

4
5
n---->
Autocorrelation Sequence

Amplitude---->

150

100
50
0

n---->

10

12

14

EXPERIMENT- 7
Aim- To perform Cross- correlation of two given sequences.
Software used- MATLAB
TheoryIn signal processing, cross-correlation is a measure of similarity of two waveforms as a function
of a time-lag applied to one of them. 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 tomographic averaging,
cryptanalysis, and neurophysiology.
The cross-correlation is similar in nature to the convolution of two functions. In an
autocorrelation, which is the cross-correlation of a signal with itself, there will always be a peak
at a lag of zero unless the signal is a trivial zero signal. In probability theory and statistics,
correlation is always used to include a standardising factor in such a way that correlations have
values between 1 and +1, and the term cross-correlation is used for referring to the correlation
corr(X, Y) between two random variables X and Y, while the "correlation" of a random vector X
is considered to be the correlation matrix (matrix of correlations) between the scalar elements of
X.

Programclc;
clear all;
x = [1 5 6 3 2 7 3];
N = length(x);
y = [2 5 7 3 2 1 4];
a = x;
z = x;
for i = 1:N-1
for i = N-1:-1:1
x(i+1) = x(i);
end
x(1) = 0;
z = [x;z;x];
end
k = z*y';
m = k'
subplot(2,1,1);
stem(a);
title('Input Sequence');
ylabel('Amplitude---->');
xlabel('n---->');
subplot(2,1,2);

stem(m);
title('Cross-correlation Sequence');
ylabel('Amplitude---->');
xlabel('n---->');

OutputInput Sequence

Amplitude---->

8
6
4
2
0

4
5
n---->
Cross-correlation Sequence

Amplitude---->

150

100
50
0

n---->

10

12

14

Você também pode gostar