Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

REPORT

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

REPORT ON MATLAB

COMMUNICATION
This is a report on matlab communication consisting of 6 experiments of
Analog and Digital Communication. This report is based on the experiments
done by us on the MATLAB and the simulation of Amplitude and Frequency
modulation.

TABLE OF CONTENTS:-
 INTRODUCTION TO MATLAB
 GENERATION OF FOLLOWING SEQUENCES
 GAUSSIAN NUMBER USING MATLAB
 AMPLITUDE MODULATION USING MATLAB CODE
 AMPLTUDE MODULATION USING SIMULINK
 FREQUENCY MODULATION USING MATLAB CODE
I would like to thank our HOD DR. TARIQUE RASHID sir who gave us
a wonderful opportunity to prepare a report on the above
experiments. It definitely helped us to understand the simulink of
various modulations using MATLAB.

BY HARSH RAJ
SEM -5TH (22- 25)LE
EXPERIMENT NO 1
AIM:-To understand the MATLAB and various commands used in MATLAB
THEORY:

MATLAB, full name MATRIX LABORATORY, is a state-of-the-art mathematical


software package, used extensively in both academia and industry. It is an interactive
program for numerical calculations and data visualization, which with its programming
capabilities provides a very useful tool for almost all fields of science and engineering.
Unlike other mathematical packages such as MAPLE or MATHEMATICAL, MATLAB
cannot perform symbolic manipulations without the use of additional toolboxes .

MATLAB is an interactive software that has recently been used in various fields of
engineering and scientific applications. It is not a computer language in the usual sense
but it performs most of the functions of a computer language. Writing computer code is
not a straightforward task, for beginners it is usually boring and time consuming. One
attractive aspect of MATLAB is that it is relatively easy to learn. It is written intuitively
and requires compilation and linking in most other programming languages.
The interactive mode of MATLAB may reduce computational speed in some applications. The

power of MATLAB is represented by the length and simplicity of the code. For example, one

page of MATLAB code may be equivalent to many pages of other computer language source

codes. Numerical calculation in MATLAB uses collections of well-written scientific/mathematical

subroutines such as LINPACK and EISPACK.


Some commonly used MATLAB commands are:
S. Command Syntax/Use
1 Clc clc
clears all input and output from the Command Window display,
giving you a "clean screen."
2 Clear all Clear all;
clear all removes all variables from the workspace, releasing them
from system memory
3 Close all Close all;
Close all deletes all figures whose handles are not hidden.
4 for for index = values
program statements
:
end

for index=values, program statements, end repeatedlyexecutes


one or more MATLAB statements in a loop. values has one of
the following forms
1) initial: end value
increments the index variable from initval to endval by 1, and
repeats execution of program statements until index is greater
than end value.
2) Initial :step :end value
increments index by the value step on each iteration, or
decrements when step is negative.
5 while while expression
program statements
:
end
while expression, program statements, end repeated executes one
or more MATLAB program statement signal, continuing until
expression no longer holds true or until MATLAB encounters a
break, or return instruction, thus forcing an immediate exit of the
loop code . If MATLAB
encounters a continue statement in the loop code, it interrupts
execution of the loop code at the location of the continue
7 input Eval Response=input(‘prompt’)

Eval Response = input(prompt) displays the prompt string on


the screen, waits for input from the keyboard, evaluates any
expression sin the input ,and returns the value in
Eval Response.
8 disp disp(X)

disp(X)display an array, without printing the array name .If X


contains a text string, the string is displayed.

Another way to display an array on the screen is to type its


name, but this prints a leading "X=," which is not always
desirable.

Note that
9 plot plot(Y)
plot(X,Y)

plot(Y) plots the columns of Y versus the index of each value


when Y is a real number .Gives a continuous plot.

plot(X,Y)plots Y vs X
8 subplot subplot(m, n, p)or subplot(m n p)

subplot(m ,n ,p) or subplot(m n p) breaks the figure window


into an m-by-n matrix of small axes, selects the axes object for
the current plot, and returns the axes handle. The axes are
counted along the top row of the figure window, then the
second row, etc.

9 title title('string')

Each axes graphics object can have on title. The title is located
at the top and in the center of the axes.
title('string') outputs the string at the top and in the center ofthe
current axes
10 max C = max(A)C=max(A,B)
C=max(A)return s the large settlements along different
dimensions of an array.
If A is a vector ,max(A)returns the large A.
C = max(A,B) returns an array the same size as A and B with
the largest elements taken from A or B. The dimensions of A
and B must match, or they may be scalar.

11 min C = min(A)C=min(A,B)

C=min(A)returns the small statements along different


dimensions of an array.
If A is a vector ,min(A)returns the small statements A.
C=min(A,B)returns an array the same size as A and B with
The small statements taken from A or B .The dimensions of A
and B must match, or they may be scalar.

12 length Number Of Elements=length(array)


number Of Elements = length(array) finds the number of
elements along the largest dimension of an array. array is an
array of any MATLAB data type and any valid dimensions.
Number Of Elements is a whole number of the MATLAB
double class.

13 sqrt B= sqrt(X)
B = sqrt(X) returns the square root of each element of the array
X. For the elements of X that are negative or complex, sqrt(X)
produces complex results
EXPERIMENT NO 2

AIM: To generate some signal sequences using MATLAB code

Theory:

A:UnitSampleSequence[(n)].
Definition-
The Dirac delta function or δ function ,is (informally)a generalized function on there a numberline
number

that is zero everywhere except at zero, with an integral of one over the entire real line. The delta
function is some times thought of as an infinitely high, infinitely thin spike at the origin, with total area
one under the spike

And which is also constrain


constrained to satisfy the identity

B:Unit Step sequence[μ(n)]


Definition-
The unit step function is just a piecewise function with a jump discontinuity at t = a. Recall from
calculus that a jump discontinuity is anx-value
anx for which the limit does not exist. The n general form
of the unit step function is given below.

Mu(t−a)=0, t<a

=M ,t>a

The M in the function represents the height of the jump and a is the number of units shifted to the
right.

C:Unit Ramp Sequence


Definition--Therampfunctionmaybedefinedanalyticallyinseveralways.Possibledefinitions
Therampfunctionmaybedefinedanalyticallyinseveralways.Possibledefinitions are:
Source code:

clc;clear
all;
closeall;
m=input('enterthevalueofm');
); n=-
10:10;
fori=1:length(n)
if n(i)==0
y(i)=1;
else
y(i)=0;
end
end
subplot(2,3,1)
stem(n,y)
xlabel('n')
ylabel('y')
title('unitsamplesequence');
);

fori=1:length(n)
ifn(i)<0||n(i)>m
y(i)=0;
else
y(i)=1;
end
end
subplot(2,3,2)
stem(n,y)
xlabel('n')
ylabel('y')
title('unitstemsequenceu(n)
'unitstemsequenceu(n)-u(n-M)');

fori=1:length(n)
if n(i)<0
y(i)=0;
else
y(i)=n(i);
end
end
subplot(2,3,3)
ylabel('y')
title('Rampsequence');
t=-pi/2:0.1:pi/2;
y=sin(2*pi*t);
subplot(2,3,4)
stem(t,y)
xlabel('t');
ylabel('y');
title('sine')
t=-pi/2:0.1:pi/2;
y=cos(2*pi*t);
subplot(2,3,5)
stem(t,y)
xlabel('t');
ylabel('y');
title('cosine')

RESULT

This is the MATLAB signal sequence generation of the above signals.


Exponential signal is given

by X(n)=(a)n

Depending upon the value of ‘a’ the exponential lcurve can be

Source Code:

clc;
a1=input('enter the value of a such that 0<=a<=1');
a2=input('enterthevalueofasuchthat-1<=a<=0');
a3=input('enter the value of a such that a<=-1');
a4=input('enter the value of a such that a>1');
forn=1:20
x1(n)=(a1)^n;
x2(n)=(a2)^n;
x3(n)=(a3)^n;
x4(n)=(a4)^n;
end
subplot(2,2,1)
stem(x1);
xlabel('-----n--->');
ylabel(' -----x1(n)-->');
title('plotofx1');

subplot(2,2,2)
stem(x2);
xlabel('-----n --->');
ylabel('-----x2(n)-->');
title('plot of x2');

subplot(2,2,3)
stem(x3);
xlabel('-----n --->');
ylabel('-----x3(n)-->');
title('plot of x3');

subplot(2,2,4)
stem(x4);
xlabel('-----n --->');
ylabel('-----x4(n)-->');
title('plot of x4');

input

enter the value of a such that 0<=a<=1


RESULT

This is the MATLAB signal sequence generation of the above waveform.


EXPERIMENT NO 3
Object4:Generate
Generate a Gaussian number with mean=20 and variance=40.Also plot the PDF of
generated number.

Theory:

The normal distributions are a very important class of statistical distributions .All
normal distributions are symmetric and have bell-shaped
bell shaped density curves with a
single peak.

To speak specifically of any normal distribution, two quantities have to be


specified: the mean ,where the peak of the density occurs, and the standard
deviation , which indicates the spread or girth of the bell curve.

In probability theory ,the normal(or Gaussian)distribution is a continuous


probability distribution,, defined by the formula

The parameter μ in this formula is the mean or expectation of the distribution (and
alsoitsmedianandmode).Theparameterσisits
).Theparameterσisitsstandarddeviation;itsvariance
varianceis
therefore σ2. A random variable with a Gaussian distribution is said to

Be normally distributed in natur


nature.
SourceCode:
cle
mean=20;
var=40;
r=normrnd(20,sqrt(40),1,200);
for i=1:200
y(i)=(1/sqrt(2*pi*var))*exp((-(r(i)-mean)^2)/(2*var));
end
stem(r,y);
xlabel('----x ---->');
ylabel('----y(x) ----->');
title('pdf of generated gaussian no.');

RESULT: This is the gaussian distribution using MATLAB code.

Object5:Generate Gaussian number with mean=0 and variance=1.Plot the generated number and
calculate 3rd moment i.e. skewness using-

Skew(X,X,...,X 1 X(j)mean

1
) ^3
1 2 n
N j0   

In probability theory and statistics, skewness is a measure of the


asymmetry of the probability distribution of a real-valued random
variable. The skewness value can be positive or negative, or even
undefined. A negative skew indicates that the tail on the left side of the
probability density function is longer than the right side and the bulk of
the values lie to the right of the mean. A positive skew indicates that the
tail on the right side is longer than the left side and the bulk of the
values lie to the left of the mean. A zero value indicates that the values
are relatively evenly distributed on both sides of the mean.

Source Code

clc;
n=50
;
r=normrnd(0,sqrt(1),1
,50); for i=1:n
y(i)=(1/sqrt(2*pi*var))*exp((-(r(i)-mean)^2)/(2*var));
end
stem
(r,y
);
xlabel(' n>');
ylabel('-----------y(x) ---- >');
title('plotofgaussianno.'
); s=0;
forx=1:n
s=s+((r(i)-mean)/var)^3;
end
skewness=
s/n;
RESULT
This is the graph showing the skewness and the level of
kurtiosisofthe normally distributed curve.
EXPERIMENT NO 4

AIM : To study AMPLITUDE MODULATION using MATLAB code

clc

t=linspace(0,0.02,10000);%definingtimerangeforthesignal
fc=10000;%frequency of carrier signal
fm=200;%frequency of message signaql
fs=40000;%sampling frequency
------------------------------------ fs>=2(
fc+BW)
Am=5;%amplitude of the message signal
Ac=10;%amplitude of the carrier signal
m=Am/Ac%modulation index for the AM wave
wc=2*pi*fc*t;%carrierfrequencyinradians
wm=2*pi*fm*t;%messagefrequencyinradians
ec=Ac*sin(wc);%carrier signal
em=Am*sin(wm);%messagesignal
y=Ac*(1+m*cos(wm)).*cos(wc);%amplitudemodulatedsigna
l z=y.*ec; %in synchronous detection the AM signal
is
%multipliedwithcarriersignalandpassedthroughLPF
%z1=conv(z,exp(-t/0.000795));%theLPFfilterresponseintimedomainis
given
%byexp(-t/RC),thecutofffrequencyforfiltershouldbefm=200
%F=1/(2*pi*R*C),replacingF=200,and
%assumingR=1kohmthenC=0.795MICROFARAD
%soRC=0.000795
%wewillgetthedemodulatedsignalbyconvolvingtheAMsignalwithLPF
%res
pons
e
l=10
000;
subplot(4,1,1),plot(t(1:l),em(1:l))
%DEPARTMENTOFELECTRONICSANDCOMMUNICATIONENGINEERING
%ANALOGCOMMUNICATIONSLAB 15
xlabel('time(sec)');
ylabel('amplitudeinvolts(
V)'); title('MODULATING
SIGNAL');
subplot(4,1,2),plot(t(1:l/2),ec(1:l/2))
xlabel('time(sec)');
ylabel('amplitudeinvolts(
V)'); title('CARRIER
SIGNAL');
subplot(4,1,3),plot(t(1:l),y(1
:l)) xlabel('time(sec)');
ylabel('amplitude in
volts(V)');
title('AMPLITUDEMODULATEDSIGNA
L');
% subplot(4,1,4),plot(t(1:l),z1(1:l))
% xlabel('time(sec)');
%ylabel('amplitudeinvolts(V)');
%title('DEMODULATEDSIGNAL');

RESULT: This is the amplitude modulation of message signal using MATLAB code.
EXPERIMENT NO 5
AIM To understand amplitude modulation
using simulink
EXPERIMENT NO 6
AIM: To understand frequency modulation
using MATLAB code
Clc

Fs=8000;%Samplingrateofsignal
Fc = 100; % Carrier frequency
t=linspace(0,1,10000);%Samplingtime
s x = sin(2*pi*10*t) % Channel 1
dev=50;%Frequencydeviationinmodulatedsignal
y=fmmod(x,Fc,Fs,dev);%Modulatebothchannels.
z=fmdemod(y,Fc,Fs,dev);%Demodulatebothchannels.

subplot(411),plot(t,x)
xlabel('time(sec)');
ylabel('amplitudeinvolts(
V)'); title('MODULATING
SIGNAL');

subplot(412),plot(t,sin(2*pi*F
c*t)) xlabel('time(sec)');
ylabel('amplitude in
volts(V)'); title('CARRIER
SIGNAL');

subplot(413),plot(t,y)
xlabel('time(sec)');
ylabel('amplitude in
volts(V)');
title('FREQUENCYMODULATEDSIGNA
L');

subplot(414),plot(t,z)
xlabel('time(sec)');
ylabel('amplitudeinvolts(
V)'); title('DEMODULATED
SIGNAL')

By writing the above source code in the editor of the MATLAB and running it, we will get the
generated frequency waveform.

You might also like