Uploaded by Ambrella Wash

lab 4

advertisement
Lab 4
SIMULATION OF COMMUNICATION SYSTEMS USING MATLAB
(AMPLITUDE MODULATION)
Objectives:
The main objective of this session is to learn the basic tools and concepts for simulating
communication systems design using MATLAB and analyze it
Description:
Our focus in this session will be on using MATLAB for simulating communication systems.
How to use full wave rectifier and filters on MATLAB. A filter in MATLAB is represented by
its transfer function. The transfer function is in general in the form of the division of two
polynomials. The filter is completely defined by the coefficients of the polynomial at the
numerator and the polynomial at the denominator. These are the vectors a and b respectively in
the program.
There are many realizations for designing filters. One common realization is Butterworth, which
is the one used here, hence the function name butter.
The butter function has two arguments. The first argument is the order of the filter. The larger
the order the sharper the filter (closer to ideal), but more processing is required. For most of our
applications an order of 3-5 should be sufficient.
The second argument is a coefficient related to the cutoff frequency. Without going into the
details of the derivation, to design a LPF filter of cutoff frequency W, the argument should be set
to 2*W*ts, where ts is the time step size of the program. For more details about the command
butter , type:
>> help butter ; in the MATLAB prompt
To apply the filter to a given signal, we use the function filter. This function has three
parameters: the coefficients of the filter a and b, and the vector to be filtered. Note that although
we think of the filter operation in frequency domain, the filter function operates on a timedomain vector.
Lab task
Matlab code for communication link
%>>>>>>>>>>>>>>>>> Program for AM transmitter and Receiver <<<<<<<<<<<<<<<%
clc
clear all
close all;
%AM TRANSMITTER %
%AM TRANSMITTER %
%AM TRANSMITTER %
%ZZZZZZZZZZZZZZZZZZ Modulating Signal Generation ZZZZZZZZZZZZZZZZZZZZZZZZZZ
A=5;
% Amplitude of
fa=50;
% Frequency of
T=1/fa;
%Period of
t=0:T/1000:2*T;
ya=3*sin(2*pi*fa*t);
% Equation for
figure(1);
subplot(3,1,1);
plot(t,ya);
% Graphical representation of
title ( '
Modulating Signal
' );
modulating Signal
modulating signal
modulating signal
% Variable time
Modulating signal
Modulating signal
xlabel ( ' time(second) ')
ylabel (' Amplitud(volt)
');
%ZZZZZZZZZZZZZZZZZZ Carrrier Signal Generation ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
A=5;
% Amplitude of Carrier Signal
fc=2000;
% Frequency of Carrier signal
yc=A*sin(2*pi*fc*t);
% Equation for carrier signal
figure(1);
subplot(3,1,2);
plot(t,yc);
% Graphical representation of carrier signal
title ( '
Carrier Signal
' );
xlabel ( ' time(second) ');
ylabel (' Amplitud(volt)
');
%ZZZZZZZZZZZZZZZZZZ AM modulated Signal Generation ZZZZZZZZZZZZZZZZZZZZZZZZ
ym=(A+ ya).*sin(2*pi*fc*t);% Equation for AM modulated signal which will be
% transmitted
figure(1)
subplot(3,1,3)
plot(t,ym)
% Graphical representation of AM modulated signal
title ( '
AM modulated Signal
' );
xlabel ( ' time(second) ');
ylabel (' Amplitud(volt)
');
%AM RECEIVER%
%AM RECEIVER%
%AM RECEIVER%
%ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ Recived signal ZZZZZZZZZZZZZZZZZZZZZZZZZZZ
ym=(A+ ya).*sin(2*pi*fc*t);
% Equation for Recived signal
figure(2)
subplot(4,1,1)
plot(t,ym)
% Graphical representation of recived signal signal
title ( '
Received Signal
' );
xlabel ( ' time(second) ');
ylabel (' Amplitud(volt)
');
%ZZZZZZZZZZZZZZZZZZ Carrrier Signal Generation ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
A=5;
% Amplitude of Carrier Signal
fc=2000;
% Frequency of Carrier signal
yc=A*sin(2*pi*fc*t);
% Equation for carrier signal
figure(2)
subplot(4,1,2);
plot(t,yc);
% Graphical representation of carrier signal
title ( '
Carrier Signal
' );
xlabel ( ' time(second) ');
ylabel (' Amplitud(volt)
');
%%ZZZZZZZZZZZZ Multiply Carrrier Signal with Received Signal%%%ZZZZZZZZZZZZZ
ymm=ym.*sin(2*pi*fc*t);
%Multiply Carrrier Signal with Received Signal
figure(2)
subplot(4,1,3);
plot(t,ymm);
title(' Received signal after Multiplication of Carrrier Signal ');
xlabel ( ' time(second) ');
ylabel (' Amplitud(volt)
');
%ZZZZZZZZZZZZZZZ Filtering to Findout Modulating Signal ZZZZZZZZZZZZZZZZZZZ
wc=200/50000;
% Normalization Cutoff Frequency
[a b]=butter(2,wc,'low');
% butterworth Low Pass Filter design
sig=filter(a,b,ymm);
% Apply given signal to Low pass filter
figure(2)
subplot(4,1,4);
plot(t,2*sig -5);% Graphical representation for outpot signal of AM receiver
title (' AM Demodulated signal ');
xlabel ( ' time(second) ');
ylabel (' Amplitud(volt)
');
Post lab questions
Q1 Which other type of filters can be used for the filtering other than Butterworth filter
Q2 Design a communication link using frequency modulation in Matlab
N=30
n=-N:1:N;
if(n<=2)
b=1;
else(n>=10)
b=6;
x = [zeros(1,N),1,zeros(1,N)];
stem(n,x)
xlabel('Sample');
ylabel('Amplitude');
title('Unit Impulse Signal');
end
Download