Introduction To Communications Toolbox in Matlab 7
Introduction To Communications Toolbox in Matlab 7
Presented By:
Amit Degada
NIT, Surat.
Electronics Engineering Department,
Sardar Vallabhbhai National Institute of Technology,
Surat-395007. [Gujarat-India]
Meaning
Presentation Outline
Objective of the Lecture
Section Overview
Expected background from the Users
Studying Components of the
Communication System
BER : As performance evaluation Technique
Scatter Plot
Simulating a Communication
Link….Examples
BERTool : A Bit Error Rate GUI
Objective of The Lecture
Introduce to Communication Toolbox in MATLAB
7.6.0 (R2008)
Analog Communications
Digital Communications
Analog Communication System
Signal De-
Modulation
Source Modulation
This may be any analog signal such as Sine wave, Cosine Wave,
Triangle Wave………………..
Analog Modulation/Demodulation
Functions
y = ammod(x,Fc,Fs)
y = ammod(x,Fc,Fs,ini_phase)
y = ammod(x,Fc,Fs,ini_phase,carramp)
Where
x = Analog Signal
Fc = Carrier Signal
Fs = Sampling Frequency
ini_phase = Initial phase of the Carrier
carramp = Carrier Amplitude
amdemod Amplitude Demodulation
Syntax
z = amdemod(y,Fc,Fs)
z = amdemod(y,Fc,Fs,ini_phase)
z = amdemod(y,Fc,Fs,ini_phase,carramp)
z = amdemod(y,Fc,Fs,ini_phase,carramp,num,den)
Where
y= Received Analog Signal
Fc = Carrier Signal
Fs = Sampling Frequency
ini_phase = Initial phase of the Carrier
carramp = Carrier Amplitude
num, den = Coefficients of butterworth low pass filter
Example……..
Amplitude Modulation Generation
y = fmmod(x,Fc,Fs,freqdev)
y = fmmod(x,Fc,Fs,freqdev,ini_phase)
Where
x = Analog Signal
Fc = Carrier Signal
Fs = Sampling Frequency
ini_phase = Initial phase of the Carrier
freqdev = Frequency deviation constant (Hz)
fmdemod Frequency Demodulation
Syntax
z = fmdemod(y,Fc,Fs,freqdev)
z = fmdemod(y,Fc,Fs,freqdev,ini_phase)
Where
Z = Received Analog Signal
Fc = Carrier Signal
Fs = Sampling Frequency
ini_phase = Initial phase of the Carrier
freqdev = Frequency deviation constant (Hz)
pmmod phase modulation
Syntax
y = pmmod(x,Fc,Fs,phasedev)
y = pmmod(x,Fc,Fs,phasedev,ini_phase)
Where
x = Analog Signal
Fc = Carrier Signal
Fs = Sampling Frequency
ini_phase = Initial phase of the Carrier
phasedev = Frequency deviation constant (Hz)
pmdemod phase Demodulation
Syntax
z = pmdemod(y,Fc,Fs,phasedev)
z = pmdemod(y,Fc,Fs,phasedev,ini_phase))
Where
x = Analog Signal
Fc = Carrier Signal
Fs = Sampling Frequency
ini_phase = Initial phase of the Carrier
phasedev = Frequency deviation constant (Hz)
Example
Statement: The example samples an analog signal and modulates it. Then
it simulates an additive white Gaussian noise (AWGN) channel,
demodulates the received signal, and plots the original and demodulated
signals.
Example
% Prepare to sample a signal for two seconds,
% at a rate of 100 samples per second.
Fs = 100; % Sampling rate
t = [0:2*Fs+1]'/Fs; % Time points for sampling
y = pmmod(x,Fc,Fs,phasedev); % Modulate.
y = awgn(y,10,'measured',103); % Add noise.
z = pmdemod(y,Fc,Fs,phasedev); % Demodulate.
Digital Pulse
Source
Modulation Shaping
Channel
Digital Matched
Sink Filter
Demodulation
Source
Results
Example
Statement : How to generate 0s and1s….
out = randint(1,7,[0,1])
Results
Digital Communication
Digital Pulse
Source
Modulation Shaping
Channel
Digital Matched
Sink Filter
Demodulation
Digital Modulation/Demodulation
fskmod Frequency shift keying modulation
fskdemod Frequency shift keying
demodulation
pskmod Phase shift keying modulation
pskdemod Phase shift keying demodulation
mskmod Minimum shift keying modulation
mskdemod Minimum shift keying
demodulation
qammod Quadrature amplitude modulation
qamdemod Quadrature amplitude demodulation
fskmod
Frequency shift keying modulation
Syntax
y = fskmod(x,M,freq_sep,nsamp)
M is the alphabet size and must be an integer power of 2. The message
signal must consist of integers between 0 and M-1.
freq_sep is the desired separation between successive frequencies in
Hz.
nsamp denotes the number of samples per symbol in y and must be a
positive integer greater than 1.
y = fskmod(x,M,freq_sep,nsamp,Fs)
%Specifies the sampling rate in Hertz
y = fskmod(x,M,freq_sep,nsamp,Fs,phase_cont)
%specifies the phase continuity. Set phase_cont to 'cont' to force phase
continuity across symbol boundaries in y, or 'discont' to avoid forcing
phase continuity. The default is 'cont'.
fskdemod
Frequency shift keying demodulation
Syntax
z = fskdemod(y,M,freq_sep,nsamp)
M is the alphabet size and must be an integer power of 2.
freq_sep is the frequency separation between successive frequencies in
Hz.
nsamp is the required number of samples per symbol and must be a
positive integer greater than 1.
z = fskdemod(y,M,freq_sep,nsamp,Fs)
%specifies the sampling frequency in Hz.
z = fskdemod(y,M,freq_sep,nsamp,Fs,symbol_order)
%specifies how the function assigns binary words to corresponding
integers. If symbol_order is set to 'bin' (default), the function uses a
natural binary-coded ordering. If symbol_order is set to 'gray', it uses a
Gray-coded ordering.
Example………
M = 2; k = log2(M);
EbNo = 5;
Fs = 16; nsamp = 17; freqsep = 8;
msg = randint(5000,1,M); % Random signal
txsig = fskmod(msg,M,freqsep,nsamp,Fs); % Modulate.
msg_rx = awgn(txsig,EbNo+10*log10(k)-10*log10(nsamp),...
'measured',[],'dB'); % AWGN channel
msg_rrx = fskdemod(msg_rx,M,freqsep,nsamp,Fs); % Demodulate
[num,BER] = biterr(msg,msg_rrx) % Bit error rate
BER_theory = berawgn(EbNo,'fsk',M,'noncoherent') % Theoretical BER
Results
Digital Communication
Digital Pulse
Source
Modulation Shaping
Channel
Digital Matched
Sink Filter
Demodulation
Pulse shaping
Syntax
y = rectpulse(x,nsamp)
% Applies rectangular pulse shaping to x to produce an output signal
having nsamp samples per symbol
Digital Communication
Digital Pulse
Source
Modulation Shaping
Channel
Digital Matched
Sink Filter
Demodulation
Channels
awgn Add white Gaussian noise to signal
rayleighchan Construct Rayleigh fading channel object
ricianchan Construct Rician fading channel object
bsc Model binary symmetric channel
Digital Pulse
Source
Modulation Shaping
Channel
Bit Error Rate
Digital Matched
Scatter Plot Sink Filter
Demodulation
Eye Diagram
Presentation Outline
Objective of the Lecture
Section Overview
Expected background from the Users
Studying Components of the
Communication System
BER : As performance evaluation Technique
Scatter Plot
Simulating a Communication
Link….Examples
BERTool : A Bit Error Rate GUI
biterr
Compute number of bit errors and
bit error rate (BER)
Syntax
[number,ratio] = biterr(x,y)
scatterplot(x)
scatterplot(x,n)
scatterplot(x,n) is the same as the first syntax, except that the function
plots every nth value of the signal, starting from the first value. That is,
the function decimates x by a factor of n before plotting.
Presentation Outline
Objective of the Lecture
Section Overview
Expected background from the Users
Studying Components of the
Communication System
BER : As performance evaluation Technique
Scatter Plot
Simulating a Communication
Link….Examples
BERTool : A Bit Error Rate GUI
Simulating a Communication
Link….Examples
Task Functions
Type
%% Signal Source
% Create a binary data stream as a column vector.
x = randint(n,1); % Random binary data stream
%% Modulation
y = modulate(modem.qammod(M),xsym); % Modulate using 16-
%QAM
Task 4 Add White Gaussian
Noise
%% Transmitted Signal
ytx = y;
%% Channel
% Send signal over an AWGN channel.
EbNo = 10; % In dB
snr = EbNo + 10*log10(k) - 10*log10(nsamp);
ynoisy = awgn(ytx,snr,'measured');
%% Received Signal
yrx = ynoisy;
Task 5 Create a Scatter Plot.
%% Scatter Plot
% Create scatter plot of noisy signal and transmitted
% signal on the same axes.
h = scatterplot(yrx(1:nsamp*5e3),nsamp,0,'g.');
hold on;
scatterplot(ytx(1:5e3),1,0,'k*',h);
title('Received Signal');
legend('Received Signal','Signal Constellation');
axis([-5 5 -5 5]); % Set axis ranges.
hold off;
Results
%% Demodulation
% Demodulate signal using 16-QAM.
zsym = demodulate(modem.qamdemod(M),yrx);
Task 7 Convert the Integer-Valued
Signal to a Binary Signal
%% Symbol-to-Bit Mapping
% Undo the bit-to-symbol mapping performed earlier.
z = de2bi(zsym,'left-msb'); % Convert integers to bits.
% Convert z from a matrix to a vector.
z = reshape(z.',prod(size(z)),1);
Task 8 Compute the System's
BER
%% BER Computation
% Compare x and z to obtain the number of errors and
% the bit error rate.
[number_of_errors,bit_error_rate] = biterr(x,z)
Results
Simulating a Communication
Link….Examples Cont
Type
Fig: Binary-Coded
16-QAM Signal
Constellation
Modifications…..
%% Modified Plot, With Gray Coding
M = 16; % Number of points in constellation
h = modem.qammod('M',M,'SymbolOrder','Gray'); % Modulator object
mapping = h.SymbolMapping; % Symbol mapping vector
pt = h.Constellation; % Vector of all points in constellation
Type
Also Define
%% Filter Definition
% Define filter-related parameters.
filtorder = 40; % Filter order
delay = filtorder/(nsamp*2); % Group delay (# of
%input samples)
rolloff = 0.25; % Rolloff factor of filter
Task 2 Create a Square Root
Raised Cosine Filter
% Create a square root raised cosine filter.
rrcfilter = rcosine(1,nsamp,'fir/sqrt',rolloff,delay);
>> bertool
In command prompt
BERTool
BERTool Environment
2. Set the parameters to reflect the system whose performance you want
to analyze. Some parameters are visible and active only when other
parameters have specific values.
3. Click Plot.
Computing Theoretical BERs
Computing Theoretical BERs
4. Change the Modulation order parameter to 16, and click Plot..
Using the Semianalytic
Technique to Compute BERs
To access the semianalytic capabilities of BERTool, open the
Semianalytic tab.
Example…..
This example illustrates how BERTool applies the semianalytic
technique, using 16-QAM modulation.
Task 1:To set up the transmitted and received signals, run steps 1
through 4 from the code example
Kapil
and
Ankurbhai
www.amitdegada.weebly.com/download
Thank You