0% found this document useful (0 votes)
234 views28 pages

Lab Manual - 801

for all ec student of vist bhopal

Uploaded by

Shivratan Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
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)
234 views28 pages

Lab Manual - 801

for all ec student of vist bhopal

Uploaded by

Shivratan Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 28

BANSAL INSTITUTE OF SCIECNCE AND TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


EC-801
ADVANCE COMMUNICATION SYSTEMS
LABORATORY MANUAL

BY
SHASHANK DUEBY
LECTURER
EC DEPTT.
EXPERIMENT 1
OBJECTIVE:
To encode and decode data using a [15,13] Reed-Solomon code for the simulation of
block codes.
INTRODUCTION:

Block codes: Block coding is a special case of error-control coding. Block coding
techniques map a fixed number of message symbols to a fixed number of code symbols.
A block coder treats each block of data independently and is a memoryless device.
The block coder input is a stream of information bits. The coder segments this bit
stream into blocks of k information bits and for each block it calculates a number of r
check bits, or it picks the r check bits from a tabulated set of values. It then transmits the
entire block, or codeword of n = k + r channel bits. This is called an (n,k) block code.
 If errors occur in sufficiently few of these transmitted channel bits, the r check
bits may provide the receiver with sufficient information to enable it to detect
and/or correct the channel errors.
 The code efficiency (or code rate) is k/n.
 If the k information bits are transmitted unaltered first followed by the
transmission of the r check bits it is called a systematic code.
 A non-systematic block code is one which has the check bits interspersed
between the information bits.
Communications Toolbox supports general linear block codes. It also includes functions
to process cyclic, LDPC, BCH, Hamming, and Reed-Solomon codes (which are all
special kinds of linear block codes). Functions in the toolbox can accomplish these
tasks:
 Encode or decode a message using one of the techniques mentioned above
 Determine characteristics of a technique, such as error-correction capability or
valid message length
 Perform lower level computations associated with a technique, such as
o Compute a decoding table
o Compute a generator or parity-check matrix
o Convert between generator and parity-check matrices
o Compute a generator polynomial
LAB WORK:
Representing Words for Reed-Solomon Codes
This toolbox supports Reed-Solomon codes that use m-bit symbols instead of
bits. A message for an [n,k] Reed-Solomon code must be a k-column Galois
array in the field GF(2m). Each array entry must be an integer between 0 and
2m-1. The code corresponding to that message is an n-column Galois array in
GF(2m). The codeword length n must be between 3 and 2m-1.
To represent words for a [7,3] Reed-Solomon code:
n = 7; k = 3; % Codeword length and message length
m = 3; % Number of bits in each symbol
msg = gf([1 6 4; 0 4 3],m); % Message is a Galois array.
c = rsenc(msg,n,k) % Code will be a Galois array.
Reed-Solomon Coding Syntaxes
This experiment illustrate how to encode and decode data using a [15,13]
Reed-Solomon code. It shows that you can
 Vary the generator polynomial for the code, using rsgenpoly to produce
a different generator polynomial.
 Vary the primitive polynomial for the Galois field that contains the
symbols, using an input argument in gf.
 Vary the position of the parity symbols within the codewords, choosing
either the end (default) or beginning.
m = 4; % Number of bits in each symbol
n = 2^m-1; k = 13; % Codeword length and message length
data = randint(4,k,2^m); % Four random integer messages
msg = gf(data,m); % Represent data using a Galois array.
% Simplest syntax for encoding
c1 = rsenc(msg,n,k);
d1 = rsdec(c1,n,k);
% Vary the generator polynomial for the code.
c2 = rsenc(msg,n,k,rsgenpoly(n,k,19,2));
d2 = rsdec(c2,n,k,rsgenpoly(n,k,19,2));
% Vary the primitive polynomial for GF(16).
msg2 = gf(data,m,25);
c3 = rsenc(msg2,n,k);
d3 = rsdec(c3,n,k);
% Prepend the parity symbols instead of appending them.
c4 = rsenc(msg,n,k,'beginning');
d4 = rsdec(c4,n,k,'beginning');
% Check that the decoding worked correctly.
chk = isequal(d1,msg) & isequal(d2,msg) & isequal(d3,msg2)
&...
isequal(d4,msg)
The output is
chk =1
Detecting and Correcting Errors in a Reed-Solomon Code
The example below illustrates the decoding results for a corrupted code. The
example encodes some data, introduces errors in each codeword, and invokes
rsdec to attempt to decode the noisy code. It uses additional output
arguments in rsdec to gain information about the success of the decoding
process.
m = 3; % Number of bits per symbol
n = 2^m-1; k = 3; % Codeword length and message length
t = (n-k)/2; % Error-correction capability of the code
nw = 4; % Number of words to process
msgw = gf(randint(nw,k,2^m),m); % Random k-symbol messages
c = rsenc(msgw,n,k); % Encode the data.
noise = (1+randint(nw,n,2^m-1)).*randerr(nw,n,t); % t
errors/row
cnoisy = c + noise; % Add noise to the code.
[dc,nerrs,corrcode] = rsdec(cnoisy,n,k); % Decode the noisy
code.
% Check that the decoding worked correctly.
isequal(dc,msgw) & isequal(corrcode,c)
nerrs % Find out how many errors rsdec corrected.
The array of noise values contains integers between 1 and 2^m, and the
addition operation c + noise takes place in the Galois field GF(2^m) because
c is a Galois array in GF(2^m).
The output from the example is below. The nonzero value of ans. indicates
that the decoder was able to correct the corrupted code words and recover the
original message. The values in the vector nerrs indicate that the decoder
corrected t errors in each codeword.
ans =
1
nerrs =
2
2
2
2
EXPERIMENT: 2
OBJECT:
To simulate Hamming code using the binary format, and a Reed-Solomon
code using the integer format.
INTRODUCTION:
Binary Format (All Coding Methods)
You can structure messages and codewords as binary vector signals, where each vector represents a
message word or a codeword. At a given time, the encoder receives an entire message word, encodes
it, and outputs the entire codeword. The message and code signals share the same sample time.

Integer Format (Reed-Solomon Only)


A message word for an [N,K] Reed-Solomon code consists of M*K bits, which you can interpret as K
symbols between 0 and 2M. The symbols are binary sequences of length M, corresponding to elements
of the Galois field GF(2M), in descending order of powers. The integer format for Reed-Solomon codes
lets you structure messages and codewords as integer signals instead of binary signals. (The input must
be a frame-based column vector.)
LAB WORK:
Hamming Code in Binary Format
This example shows very simply how to use an encoder and decoder. It illustrates the appropriate
vector lengths of the code and message signals for the coding blocks. Because the Error Rate
Calculation block accepts only scalars or frame-based column vectors as the transmitted and received
signals, this example uses frame-based column vectors throughout. (It thus avoids having to change
signal attributes using a block such as Convert 1-D to 2-D.)
To build the model, gather and configure these blocks:
 Bernoulli Binary Generator, in the Comm Sources library
o Set Probability of a zero to .5.
o Set Initial seed to any positive integer scalar, preferably the output of the randseed
function.
o Check the Frame-based outputs check box.
o Set Samples per frame to 4.
 Hamming Encoder, with default parameter values
 Hamming Decoder, with default parameter values
 Error Rate Calculation, in the Comm Sinks library, with default parameter values
Connect the blocks as in the preceding figure. Use the Signal dimensions feature from the Port/signal
displays submenu of the model window's Format menu. After updating the diagram if necessary
(Update diagram from the Edit menu), the connector lines show relevant signal attributes. The
connector lines are double lines to indicate frame-based signals, and the annotations next to the lines
show that the signals are column vectors of appropriate sizes.
Reed-Solomon Code in Integer Format
This example uses a Reed-Solomon code in integer format. It illustrates the appropriate vector lengths
of the code and message signals for the coding blocks. It also exhibits error correction, using a very
simple way of introducing errors into each codeword.

Reed-Solomon Code in Integer Format

Unbuffer Scope

Random -K-
RS Encoder RS DecoderErr
Integer
Gain
Random-Integer Integer-Input Integer-Output
Generator RS Encoder RS Decoder
Unbuffer1 Scope1

Info
To build the model, gather and configure these blocks:
 Random Integer Generator, in the Comm Sources library
o Set M-ary number to 15.
o Set Initial seed to a positive number, randseed(0) is chosen here.
o Check the Frame-based outputs check box.
o Set Samples per frame to 5.
 Integer-Input RS Encoder
o Set Codeword length N to 15.
o Set Message length K to 5.
 Gain, in the Simulink Math Operations library
o Set Gain to [0; 0; 0; 0; 0; ones(10,1)].
 Integer-Output RS Decoder
o Set Codeword length N to 15.
o Set Message length K to 5.
 Scope, in the Simulink Sinks library. Get two copies of this block.
 Sum, in the Simulink Math Operations library
o Set List of signs to |-+
Connect the blocks as in the preceding figure. From the model window's Simulation menu, select
Configuration parameters. In the Configuration Parameters dialog box, set Stop time to 500.
The vector length numbers appear on the connecting lines only if you select Signal dimensions from
the Port/signal displays submenu of the model's Format menu. The encoder accepts a vector of
length 5 (which is K in this case) and produces a vector of length 15 (which is N in this case). The
decoder does the opposite.
Running the model produces the following scope images. Your plot of the error counts might differ
somewhat, depending on your Initial seed value in the Random Integer Generator block. (To make the
axis range exactly match that of the first scope, right-click the plot area in the scope and select Axes
properties.)
EXPERIMENT 3
OBJECT:
To design and simulate a rate 2/3 feed forward convolutional Encoder .
INTODUCTION:
Convolutional coding is a special case of error-control coding. Unlike a block coder, a convolutional
coder is not a memoryless device. Even though a convolutional coder accepts a fixed number of
message symbols and produces a fixed number of code symbols, its computations depend not only on
the current set of input symbols but on some of the previous input symbols.

Parameters for Convolutional Coding


To process convolutional codes, use the Convolutional Encoder, Viterbi Decoder, and/or APP Decoder
blocks in the Convolutional sublibrary. If a mask parameter is required in both the encoder and the
decoder, use the same value in both blocks.
The blocks in the Convolutional sublibrary assume that you use one of two different representations of
a convolutional encoder:
 If you design your encoder using a diagram with shift registers and modulo-2 adders, you can
compute the code generator polynomial matrix and subsequently use the poly2trellis function
(in Communications Toolbox) to generate the corresponding trellis structure mask parameter
automatically. For an example, see Example: A Rate 2/3 Feedforward Encoder.
 If you design your encoder using a trellis diagram, you can construct the trellis structure in
MATLAB and use it as the mask parameter.
Details about these representations are in the sections Polynomial Description of a Convolutional
Encoder and Trellis Description of a Convolutional Encoder in the Communications Toolbox User's
Guide.
LAB WORK:
In this experiment the rate 2/3 feedforward convolutional encoder depicted in the following figure. The
description explains how to determine the coding blocks' parameters from a schematic of a rate 2/3
feedforward encoder. This example also illustrates the use of the Error Rate Calculation block with a
receive delay.
How to Determine Coding Parameters
The Convolutional Encoder and Viterbi Decoder blocks can implement this code if their parameters
have the appropriate values. The encoder's constraint length is a vector of length 2 since the encoder
has two inputs. The elements of this vector indicate the number of bits stored in each shift register,
including the current input bits. Counting memory spaces in each shift register in the diagram and
adding one for the current inputs leads to a constraint length of [5 4].
To determine the code generator parameter as a 2-by-3
matrix of octal numbers, use the element in the ith row and jth column to indicate how the ith input
contributes to the jth output. For example, to compute the element in the second row and third column,
notice that the leftmost and two rightmost elements in the second shift register of the diagram feed into
the sum that forms the third output. Capture this information as the binary number 1011, which is
equivalent to the octal number 13. The full value of the code generator matrix is [27 33 0; 0 5 13].
To use the constraint length and code generator parameters in the Convolutional Encoder and Viterbi
Decoder blocks, use the poly2trellis function to convert those parameters into a trellis structure.

How to Simulate the Encoder


The following model simulates this encoder.

A Rate 2/3 Feedforward Convolutional Encoder

Tx
Error Rate
Convolutional Calculation
Bernoulli BS C Rx
Encoder Viterbi Decoder
Binary
Error Rate Calculation
Bernoulli Random Bina ry S ymme tric
Convolutional Viterbi Decoder Display
Binary Generator Cha nne l
Encoder

Info

To build the model, gather and configure these blocks:


 Bernoulli Binary Generator, in the Comm Sources library
o Set Probability of a zero to .5.
o Set Initial seed to any positive integer scalar, preferably the output of the randseed
function.
o Set Sample time to .5.
o Check the Frame-based outputs check box.
o Set Samples per frame to 2.
 Convolutional Encoder
o Set Trellis structure to poly2trellis([5 4],[23 35 0; 0 5 13]).
 Binary Symmetric Channel, in the Channels library
o Set Error probability to 0.02.
o Set Initial seed to any positive integer scalar, preferably the output of the randseed
function.
o Clear the Output error vector check box.
 Viterbi Decoder
o Set Trellis structure to poly2trellis([5 4],[23 35 0; 0 5 13]).
o Set Decision type to Hard Decision.
 Error Rate Calculation, in the Comm Sinks library
o Set Receive delay to 68.
o Set Output data to Port.
o Check the Stop simulation check box.
o Set Target number of errors to 100.
 Display, in the Simulink Sinks library
o Drag the bottom edge of the icon to make the display big enough for three entries.
Connect the blocks as in the figure. From the model window's Simulation menu, select Configuration
parameters. In the Configuration Parameters dialog box, set Stop time to inf.

EXPERIMENT 4
OBJECT:
Simulation of Low-Density Parity-Check (LDPC) codes with LDPC encoder and decoder.

INTRODUCTION :
Low-Density Parity-Check (LDPC) codes are linear error control codes with:
 Sparse parity-check matrices
 Long block lengths that can attain performance near the Shannon limit (see fec.ldpcenc and
fec.ldpcdec)
The decoding process is done iteratively. If the number of iterations is too small, the algorithm may not
converge. You may need to experiment with the number of iterations to find an appropriate value for
your model. For details on the decoding algorithm, see Decoding Algorithm.
Unlike some other codecs, you cannot connect an LDPC
decoder directly to the output of an LDPC encoder, because the decoder requires log-likelihood ratios
(LLR). Thus, you may use a demodulator to compute the LLRs.

LAB WORK:

LDPC Encoding Method


This object has a method encode that is used to encode signals.
codeword = encode(l, msg) encodes msg using the LDPC code specified by the LDPC encoder object
l. msg must be a binary 1-by-NumInfoBits vector.
codeword is a binary 1-by-BlockLength vector. The first NumInfoBits bits are the information bits
(msg) and the last NumParityBits bits are the parity bits. The modulo-2 matrix product of
ParityCheckMatrix and codeword' is a zero vector.

This program demonstrates the use of this object.


% Construct a default LDPC encoder object
l = fec.ldpcenc;
% Generate a random binary message
msg = randint(1,l.NumInfoBits,2);

% Encode the message


codeword = encode(l, msg);

% Verify the parity checks (which should be a zero vector)


paritychecks = mod(l.ParityCheckMatrix * codeword', 2);

Decoding Method

This object has a method decode that is used to decode signals.


decoded = decode(l, llr) decodes an LDPC code using the message-passing algorithm, where l is
an LDPC decoder object and llr is a 1-by-BlockLength vector.
The results returned in decoded depends on the parameters of the LDPC decoder object.

If the property... is set to... then decoded is...


DecisionType 'Hard decision' The decoded bits. See Decoding Algorithm.
DecisionType 'Soft decision' The log-likelihood ratios for the decoded bits.
OutputFormat 'Information part' A 1-by-NumInfoBits vector.

OutputFormat 'Whole codeword' A 1-by-BlockLength vector.

This method uses the properties DecisionType, OutputFormat, NumIterations, and


DoParityChecks, and updates the values for FinalParityChecks, and ActualNumIterations.

Decoding Algorithm

This program demonstrates the use of this object.


enc = fec.ldpcenc; % Construct a default LDPC encoder object

% Construct a companion LDPC decoder object


dec = fec.ldpcdec;
dec.DecisionType = 'Hard decision';
dec.OutputFormat = 'Information part';
dec.NumIterations = 50;
% Stop if all parity-checks are satisfied
dec.DoParityChecks = 'Yes';

% Generate and encode a random binary message


msg = randint(1,enc.NumInfoBits,2);
codeword = encode(enc,msg);

% Construct a BPSK modulator object


modObj = modem.pskmod('M',2,'InputType','Bit');

% Modulate the signal (map bit 0 to 1 + 0i, bit 1 to -1 + 0i)


modulatedsig = modulate(modObj, codeword);
% Noise parameters
SNRdB = 1;
sigma = sqrt(10^(-SNRdB/10));

% Transmit signal through AWGN channel


receivedsig = awgn(modulatedsig, SNRdB, 0); ...
% Signal power = 0 dBW

% Visualize received signal


scatterplot(receivedsig)
% Construct a BPSK demodulator object to compute
% log-likelihood ratios
demodObj = modem.pskdemod(modObj,'DecisionType','LLR', ...
'NoiseVariance',sigma^2);

% Compute log-likelihood ratios (AWGN channel)


llr = demodulate(demodObj, receivedsig);

% Decode received signal


decodedmsg = decode(dec, llr);

% Actual number of iterations executed


disp(['Number of iterations executed = ' ...
num2str(dec.ActualNumIterations)]);
% Number of parity-checks violated
disp(['Number of parity-checks violated = ' ...
num2str(sum(dec.FinalParityChecks))]);
% Compare with original message
disp(['Number of bits incorrectly decoded = ' ...
num2str(nnz(decodedmsg-msg))]);
EXPERIMET 5

OBJECT:
Simulation of end-to-end baseband model of the physical layer of an OFDM based wireless
metropolitan area network (WMAN) according to the IEEE® 802.16-2004 standard.
This demo represents an end-to-end baseband model of the
physical layer of a wireless metropolitan area network (WMAN) according to the IEEE® 802.16-2004
standard. More specifically, it models the OFDM-based physical layer called WirelessMAN-OFDM,
supporting all of the mandatory coding and modulation options. It also illustrates Space-Time Block
Coding (STBC), an optional transmit diversity scheme specified for use on the downlink.

Contents
 Structure of the Demo
 Exploring the Demo
 Results and Displays
 Available Demo Models
 Selected References

Structure of the Demo


This demo showcases the main components of the WMAN 802.16-2004 OFDM physical layer using
two models: one with STBC and one without, which has all the mandatory coding and modulation
options.
IEEE 802.16-2004 OFDM PHY link, Including Space-Time Block Coding
Model IEEE 802.16-2004 Standard Specification
Parameters http://ieee802.org/16/pubs/80216-2004.html This model creates files in the current folder.
The current folder must be writable.
Double-click to
set model parameters

Bernoulli OFDM Transmitter


Binary FEC & IFFT Input Space-Time
Modulator Bank Packing Diversity Encoder
Random Data [rateID] OFDM Transmitter
Source

MISO
Double-click to set Channel
channel parameters 2x1
BER
Bit Error Rate
[rateID] #Errors
Calculation
#Bits
Bit Error Rate AWGN
Double-click to set
Display Channel
AWGN variance
Rx Constellation

Extract Space-Time OFDM


Demodulator Data Carriers Diversity Combiner Receiver
& FEC Bank
[rateID]

Adaptive
SNR
Rate [rateID]
Estimation
Control
u-1
Double-click to open
Info RateID link model w ithout
Copyright 2007-2008 The MathWorks, Inc. Space-Time Block Coding
Est. SNR (dB)

The tasks performed in the communication system models include:


 Generation of random bit data that models a downlink burst consisting of an integer number of
OFDM symbols.
 Forward Error Correction (FEC), consisting of a Reed-Solomon (RS) outer code concatenated
with a rate-compatible inner convolutional code (CC).
 Data interleaving.
 Modulation, using one of the BPSK, QPSK, 16-QAM or 64-QAM constellations specified.
 Orthogonal Frequency Division Multiplexed (OFDM) transmission using 192 sub-carriers, 8
pilots, 256-point FFTs, and a variable cyclic prefix length.
 Space-Time Block Coding using Alamouti's scheme. This is implemented using the OSTBC
Encoder and Combiner blocks in Communications Blockset.
 A single OFDM symbol length preamble that is used as the burst preamble. For the optional
STBC model, the single symbol preamble is transmitted from both antennas.
 A Multiple-Input-Single-Output (MISO) fading channel with AWGN for the STBC model. A
choice of non-fading, flat-fading or dispersive multipath fading channel for the non-STBC
model.
 OFDM receiver that includes channel estimation using the inserted preambles. For the STBC
model, this implies diversity combining as per .
 Hard-decision demodulation followed by deinterleaving, Viterbi decoding, and Reed-Solomon
decoding.
Both models also use an adaptive-rate control scheme based on SNR estimates at the receiver to vary
the data rate dynamically based on the channel conditions. The models use the standard specified set of
seven rates for OFDM-PHY, each corresponding to a specific modulation and RS-CC code rate as
denoted by rate_ID .
The STBC link model uses a MISO fading channel to model a two transmitter, one receiver (2x1)
system. The fading parameters specified are assumed to be identical for the two links. The Space-Time
Diversity Combiner block uses the channel estimates for each link and combines the received signals
as per . The combining involves simple linear processing using the orthogonal signalling employed by
the encoder.
Furthermore, the models include blocks for measuring and displaying the bit error
rate after FEC, the channel SNR and the rate_ID. A scatter plot scope is used to display the received
signal, which helps users visualize channel impairments and modulation adaptation as the simulation
runs. The subsystems and blocks used in the models are color-coded to make viewing easier. The
communication system operations are in blue, control systems and signals are in orange and the
performance evaluation, displays and plots are in yellow.
To view any of these operations in detail, double-click
the corresponding subsystem to open the underlying subsystem implementation. For the ones that have
mask dialogs, choose Look Under Mask from the window's Edit menu. Simplifications and
Assumptions
For simplicity, the models in this demo:
 Set the number of OFDM symbols to be constant for all data bursts generated. As a result, for
any given profile, the frame duration in Simulink remains the same. Also, within the downlink
frame only the downlink bursts are modelled, i.e. the long preamble and the FCH burst are not
modelled.
 Do not model the Randomization specified as a part of the channel coding as the data is
randomly generated. The library file has blocks which cover this functionality.
 Assume perfect synchronization between the transmitter and receiver. As a consequence, they
only use a short preamble for every downlink burst.
 At the receiver, estimate the channel using only the inserted preambles and not the pilot
subcarriers. This assumes that the channel is not changing very rapidly (or is constant for the
number of OFDM symbols in a burst).

Exploring the Demo
The Model Parameters configuration block on both models allows you to choose and specify system
parameters such as channel bandwidth, number of OFDM symbols per burst and the cyclic prefix
factor. Varying these parameter values allows you to experiment with the different WiMAX profiles as
defined by the WiMAX Forum [ 5 ], and gauge the system performance for each.
The other parameter of interest is the Low SNR thresholds for rate control
parameter, as it directly affects the adaptive-rate control in the two models. This parameter is a six-
element vector representing the boundaries between the adjoining seven SNR ranges that correspond to
the seven rates. Ideally, the simulation should use the highest throughput mode that achieves the
desired bit error rate. Another area of variability includes the channel blocks in the two models. The
models allow you to vary the fading parameters [ 2 ] and the AWGN variance (in SNR mode) added to
the signal. As a result, you can examine how well the receiver performs with different fade
characteristics (choosing the appropriate K factor, maximum Doppler shift, number of paths, path
gains) and generate BER curves for varying SNR values.

Results and Displays


When either of the two models are simulated, windows come up automatically to display the spectrum
plots of the transmitted signal per antenna and a scatter plot of the received signal prior to
demodulation.
Simplifications and Assumptions
For simplicity, the models in this demo:
 Set the number of OFDM symbols to be constant for all data bursts generated. As a result, for
any given profile, the frame duration in Simulink remains the same. Also, within the downlink
frame only the downlink bursts are modelled, i.e. the long preamble and the FCH burst are not
modelled.
 Do not model the Randomization specified as a part of the channel coding as the data is
randomly generated. The library file has blocks which cover this functionality.
 Assume perfect synchronization between the transmitter and receiver. As a consequence, they
only use a short preamble for every downlink burst.
 At the receiver, estimate the channel using only the inserted preambles and not the pilot
subcarriers. This assumes that the channel is not changing very rapidly (or is constant for the
number of OFDM symbols in a burst).

Exploring the Demo


The Model Parameters configuration block on both models allows you to choose and specify system
parameters such as channel bandwidth, number of OFDM symbols per burst and the cyclic prefix
factor. Varying these parameter values allows you to experiment with the different WiMAX profiles as
defined by the WiMAX Forum [ 5 ], and gauge the system performance for each. The other parameter
of interest is the Low SNR thresholds for rate control parameter, as it directly affects the adaptive-
rate control in the two models. This parameter is a six-element vector representing the boundaries
between the adjoining seven SNR ranges that correspond to the seven rates. Ideally, the simulation
should use the highest throughput mode that achieves the desired bit error rate. Another area of
variability includes the channel blocks in the two models. The models allow you to vary the fading
parameters [ 2 ] and the AWGN variance (in SNR mode) added to the signal. As a result, you can
examine how well the receiver performs with different fade characteristics (choosing the appropriate K
factor, maximum Doppler shift, number of paths, path gains) and generate BER curves for varying
SNR values.

Results and Displays


When either of the two models are simulated, windows come up automatically to display the spectrum
plots of the transmitted signal per antenna and a scatter plot of the received signal prior to
demodulation.
EXPERIMENT :6
OBJECT:
Simulation of transmission through a Rayleigh fading channel.

INTRODUCTION:
Rayleigh and Rician fading channels are useful models of real-world phenomena in wireless
communication. These phenomena include multipath scattering effects, time dispersion, and Doppler
shifts that arise from relative motion between the transmitter and receiver.
This demo shows how to use the following in order to model a fading channel:
1. Rayleigh and Rician multipath fading channel objects
2. Channel visualization tool
Processing a signal using a fading channel involves the following steps:
1. Create a channel object that describes the channel that you want to use. A channel object is a
type of MATLAB® variable that contains information about the channel, such as the maximum
Doppler shift.
2. Adjust properties of the channel object, if necessary, to tailor it to your needs. For example, you
can change the path delays or average path gains.
3. Apply the channel object to your signal using the filter function, which has been overloaded to
work with channel objects.
The characteristics of a channel can be plotted using the channel visualization tool.

LAB WORK:
Contents
 Initialization
 Creating Channel Objects
 Modulation and Channel Filtering
 Visualization
 Narrowband or Frequency-Flat Fading
 Rician Fading
 Wideband or Frequency Selective Channel
Initialization
The following variables control both the Rayleigh and Rician channel objects. By default, the channel
is modeled as four fading paths, each representing a cluster of multipath components received at
around the same delay.
sampleTime = 1/500000; % Sample time (s)
maxDopplerShift = 200; % Maximum Doppler shift of diffuse components (Hz)
delayVector = 1.0e-004 * [0 0.0400 0.0800 0.1200]; % Discrete delays of
% four-path channel (s)
gainVector = [0 -3 -6 -9]; % Average path gains (dB)
The maximum Doppler shift is computed as v*f/c, where v is the mobile speed, f is the carrier
frequency, and c is the speed of light. For example, a maximum Doppler shift of 200 Hz (as above)
corresponds to a mobile speed of 65 mph (30 m/s) and a carrier frequency of 2 GHz.
By convention, the delay of the first path is typically set to zero. For subsequent paths, a 1
microsecond delay corresponds to a 300 m difference in path length. In some outdoor multipath
environments, reflected paths can be up to several kilometers longer than the shortest path. With the
path delays specified above, the last path is 3.6 km longer than the shortest path, and thus arrives 12
microseconds later.
Together, the path delays and path gains specify the channel's average delay
profile. Typically, the average path gains decay exponentially with delay (i.e., the dB values decay
linearly), but the specific delay profile depends on the propagation environment. In the delay profile
specified above, we assume a 3 dB decrease in average power for every 4 microseconds of path delay.
The following variables control the Rician channel object. The Doppler shift of the specular
component is typically smaller than the maximum Doppler shift (above) and depends on the mobile's
direction of travel relative to the direction of the specular component. The K-factor specifies the linear
ratio of average received power from the specular component relative to that of the associated diffuse
components.
specDopplerShift = 100; % Doppler shift of specular component (Hz)
KFactor = 10; % Linear ratio of specular power to diffuse power

Creating Channel Objects


With the parameters specified above, we can now create the Rayleigh and Rician channel objects using
the RAYLEIGHCHAN and RICIANCHAN functions.
% Create Rayleigh channel object
rayChanObj = rayleighchan(sampleTime, maxDopplerShift, delayVector,...
gainVector) ;
rayChanObj.StoreHistory = 1; % Store channel state information as signal is
% processed for later visualization
% Create Rician channel object
ricChanObj = ricianchan(sampleTime, maxDopplerShift, KFactor, ...
delayVector, gainVector, specDopplerShift);
ricChanObj.StoreHistory = 1; % Store channel state information as signal is
% processed for later visualization

Modulation and Channel Filtering


The MODEM.PSKMOD function can be used to create a PSK modulator object The modulation object
can then be used to modulate the channel data, which has been generated using the RANDINT
function here. Note that in the code below a 'frame' refers to a vector of information bits.
% QPSK modulation with a phase offset of pi/4 is used for this demo
phaseOff = pi/4;
modObj = modem.pskmod(4, phaseOff);
modObj.InputType = 'Bit';

% Number of bits transmitted per frame is set to be 1000. For QPSK


% modulation, this corresponds to 500 symbols per frame.
bitsPerFrame = 1000;
msg = randint(bitsPerFrame,1);

% Modulate data for transmission over channel


modSignal = modulate(modObj, msg);

% Apply channel object on the modulated data using the FILTER function
filter(rayChanObj,modSignal);
filter(ricChanObj, modSignal);

Visualization
The Communications Toolbox™ provides a plotting function that helps you visualize the
characteristics of a fading channel using a GUI. The channel visualization tool can be invoked using
the PLOT or the CHANNEL_VIS function.
Using option 'IR' opens the visualization for the bandlimited impulse response (green curve). The
visualization also shows the delays and magnitudes of the underlying fading path gains
(red/magenta/blue stembars) clustered around the peak of the impulse response. Since the channel's
delay span (12 microseconds) is much smaller than our QPSK symbol period (100 microseconds),
these components cause minimal time dispersion. The resultant bandlimited impulse response closely
approximates a sinc pulse and thus has very small intersymbol interference (ISI) components (green
circles).
Note: For path gains, red corresponds to the smallest path delay while blue corresponds to the largest.
Components with intermediate delay values are shades between red and blue, becoming more blue for
larger delays.
channel_vis(rayChanObj, 'Visualization', 'ir'); % View Impulse Response
channel_vis(rayChanObj, 'Animation', 'medium'); % Set animation speed
channel_vis(rayChanObj, 'SampleIndex', 1); % Set animation start point

% Note: In this plot, the gains do not equal the average path gains because
% the Doppler effect causes the gains to fluctuate around their average
% values over time

Narrowband or Frequency-Flat Fading


If the bandwidth is too small for the signal to resolve the individual components, the frequency
response is approximately flat because of the minimal time dispersion caused by the multipath channel.
This kind of low-dispersion multipath fading is often referred to as narrowband fading, or frequency-
flat fading.
channel_vis(rayChanObj, 'close'); % Close Channel Visualization Tool
sampleTime = 1/20000; % 20 kb/s transmission

% Set data characteristics


bitsPerFrame = 1000;
numFrames = 20;

% Create a Rayleigh channel object


rayChanObj = rayleighchan(sampleTime, maxDopplerShift, delayVector,...
gainVector) ;
rayChanObj.StoreHistory = 1;
rayChanObj.ResetBeforeFiltering = 0; % Retain channel states across
% multiple frames

% Process multiple frames


for i = 1:numFrames
msg = randint(bitsPerFrame,1); % Create data
modSignal = modulate(modObj, msg); % Modulate data
filter(rayChanObj,modSignal); % Apply channel filtering to the data
channel_vis(rayChanObj, 'Visualization', 'fr'); % Frequency response
plot(rayChanObj);
end

% Visualize the channel frequency response


channel_vis(rayChanObj, 'Animation', 'medium');
channel_vis(rayChanObj, 'SampleIndex', 1);
Note that all delayed components combine at a single delay (in this case, at zero). Using the "Multipath
gain" visualization, you can validate this narrowband fading behavior. When the signal's fading
envelope (blue dashed curve) closely approximates the "Narrowband" curve (magenta dots), you can
regard the channel as exhibiting narrowband fading.
channel_vis(rayChanObj, 'Visualization', 'gain');
To simplify and speed up modeling, narrowband fading channels are typically modeled as a single-
path fading channel. (That is, a multiple-path fading model overspecifies a narrowband fading
channel.) The following settings correspond to a narrowband fading channel. Notice that the shape of
the bandlimited impulse response is also flat.
delayVector = 0; % Single fading path with zero delay
gainVector = 0; % Average path gain of 1 (0 dB)
channel_vis(rayChanObj, 'close');

% Set data characteristics


bitsPerFrame = 1000;
numFrames = 100;

% Create a Rayleigh channel object


rayChanObj = rayleighchan(sampleTime, maxDopplerShift, delayVector,...
gainVector) ;
rayChanObj.StoreHistory = 1;
rayChanObj.ResetBeforeFiltering = 0;

% Process multiple frames


for i = 1:numFrames
msg = randint(bitsPerFrame,1); % Create data
modSignal = modulate(modObj, msg); % Modulate data
filter(rayChanObj,modSignal); % Apply channel filtering to data
channel_vis(rayChanObj, 'Visualization', 'fr'); % Frequency response
plot(rayChanObj);
end

% View channel frequency response


channel_vis(rayChanObj, 'Visualization', 'fr');
channel_vis(rayChanObj, 'Animation', 'medium');
channel_vis(rayChanObj, 'SampleIndex', 1);
The single-path fading channel is modeled as a complex gain, which captures both the attenuation and
phase shift of the channel. The "Phasor trajectory" visualization shows how this complex gain changes
over a transmitted frame. The blue line is the phasor of the path, and the green line is its trajectory over
time. The signal experiences a deep fade when this trajectory passes through or near zero.
channel_vis(rayChanObj, 'Visualization', 'phasor');
channel_vis(rayChanObj, 'Animation', 'slow');
channel_vis(rayChanObj, 'SampleIndex', 1);
The "Multipath gain" visualization shows the dB gain of the fading channel. The magnitude fluctuates
over a 30-40 dB range in the Rayleigh fading channel.
channel_vis(rayChanObj, 'Visualization', 'gain');
The Doppler spectrum is a statistical characterization of the fading process. The channel visualization
tool makes periodic measurements of the Doppler spectrum (blue dots). Over time, the average of this
measurement better approximates the theoretical Doppler spectrum (red dashed curve). A close
approximation indicates good statistical coverage by the Rayleigh fading process.
channel_vis(rayChanObj, 'close');

% View Doppler spectrum


channel_vis(rayChanObj, 'Visualization', 'doppler');

EXPERIMENT : 7
OBJECT:
Simulation of Multiple-Input-Multiple-Output (MIMO) systems, which use multiple antennas at the
transmitter and receiver ends of a wireless communication system.

INTRODUCTION:
This demo introduces Multiple-Input-Multiple-Output (MIMO) systems, which use multiple antennas
at the transmitter and receiver ends of a wireless communication system. MIMO systems are
increasingly being adopted in communication systems for the potential gains in capacity they realize
when using multiple antennas. Multiple antennas use the spatial dimension in addition to the time and
frequency ones, without changing the bandwidth requirements of the system.
For a generic communications link, this demo focuses on transmit diversity in lieu of traditional
receive diversity. Using the flat-fading Rayleigh channel, it illustrates the concept of Orthogonal
Space-Time Block Coding, which is employable when multiple transmitter antennas are used. It is
assumed here that the channel undergoes independent fading between the multiple transmit-receive
antenna pairs.
For a chosen system, it also provides a measure of the performance degradation when the channel is
imperfectly estimated at the receiver, compared to the case of perfect channel knowledge at the
receiver.
Contents
 PART 1: Transmit Diversity vs. Receive Diversity
 PART 2: Space-Time Block Coding with Channel Estimation
 PART 3: Orthogonal Space-Time Block Coding and Further Explorations
PART 1: Transmit Diversity vs. Receive Diversity
Using diversity reception is a well-known technique to mitigate the effects of fading over a
communications link. However, it has mostly been relegated to the receiver end. In [1], Alamouti
proposes a transmit diversity scheme that offers similar diversity gains, using multiple antennas at the
transmitter. This was conceived to be more practical as, for example, it would only require multiple
antennas at the base station in comparison to multiple antennas for every mobile in a cellular
communications system.
This section highlights this comparison of transmit vs. receive diversity by simulating coherent binary
phase-shift keying (BPSK) modulation over flat-fading Rayleigh channels. For transmit diversity, we
use two transmit antennas and one receive antenna (2x1 notationally), while for receive diversity we
employ one transmit antenna and two receive antennas (1x2 notationally).
The simulation covers an end-to-end system showing the encoded and/or transmitted signal, channel
model, and reception and demodulation of the received signal. It also provides the no-diversity link
(single transmit- receive antenna case) and theoretical performance of second-order diversity link for
comparison. It is assumed here that the channel is known perfectly at the receiver for all systems. We
run the simulation over a range of Eb/No points to generate BER results that allow us to compare the
different systems.
We start by defining some common simulation parameters
frmLen = 100; % frame length
numPackets = 1000; % number of packets
EbNo = 0:2:20; % Eb/No varying to 20 dB
N = 2; % maximum number of Tx antennas
M = 2; % maximum number of Rx antennas
and set up the simulation.
% Seed states for repeatability
seed = [98765 12345]; randn('state', seed(1)); rand('state', seed(2));

% Create BPSK mod-demod objects


P = 2; % modulation order
bpskmod = modem.pskmod('M', P, 'SymbolOrder', 'Gray');
bpskdemod = modem.pskdemod(bpskmod);

% Pre-allocate variables for speed


tx2 = zeros(frmLen, N); H = zeros(frmLen, N, M);
r21 = zeros(frmLen, 1); r12 = zeros(frmLen, 2);
z21 = zeros(frmLen, 1); z21_1 = zeros(frmLen/N, 1); z21_2 = z21_1;
z12 = zeros(frmLen, M);
error11 = zeros(1, numPackets); BER11 = zeros(1, length(EbNo));
error21 = error11; BER21 = BER11; error12 = error11; BER12 = BER11; BERthy2 = BER11;
% Set up a figure for visualizing BER results
h = gcf; grid on; hold on;
set(gca, 'yscale', 'log', 'xlim', [EbNo(1), EbNo(end)], 'ylim', [1e-5 1]);
xlabel('Eb/No (dB)'); ylabel('BER'); set(h,'NumberTitle','off');
set(h, 'renderer', 'zbuffer'); set(h,'Name','Transmit vs. Receive Diversity');
title('Transmit vs. Receive Diversity');

% Loop over several EbNo points


for idx = 1:length(EbNo)
% Loop over the number of packets
for packetIdx = 1:numPackets
data = randint(frmLen, 1, P); % data vector per user per channel
tx = modulate(bpskmod, data); % BPSK modulation

% Alamouti Space-Time Block Encoder, G2, full rate


% G2 = [s1 s2; -s2* s1*]
s1 = tx(1:N:end); s2 = tx(2:N:end);
tx2(1:N:end, :) = [s1 s2];
tx2(2:N:end, :) = [-conj(s2) conj(s1)];

% Create the Rayleigh distributed channel response matrix


% for two transmit and two receive antennas
H(1:N:end, :, :) = (randn(frmLen/2, N, M) + ...
j*randn(frmLen/2, N, M))/sqrt(2);
% assume held constant for 2 symbol periods
H(2:N:end, :, :) = H(1:N:end, :, :);

% Received signals
% for uncoded 1x1 system
r11 = awgn(H(:, 1, 1).*tx, EbNo(idx));

% for G2-coded 2x1 system - with normalized Tx power, i.e., the


% total transmitted power is assumed constant
r21 = awgn(sum(H(:, :, 1).*tx2, 2)/sqrt(N), EbNo(idx));

% for Maximal-ratio combined 1x2 system


for i = 1:M
r12(:, i) = awgn(H(:, 1, i).*tx, EbNo(idx));
end

% Front-end Combiners - assume channel response known at Rx


% for G2-coded 2x1 system
hidx = 1:N:length(H);
z21_1 = r21(1:N:end).* conj(H(hidx, 1, 1)) + ...
conj(r21(2:N:end)).* H(hidx, 2, 1);

z21_2 = r21(1:N:end).* conj(H(hidx, 2, 1)) - ...


conj(r21(2:N:end)).* H(hidx, 1, 1);
z21(1:N:end) = z21_1; z21(2:N:end) = z21_2;

% for Maximal-ratio combined 1x2 system


for i = 1:M
z12(:, i) = r12(:, i).* conj(H(:, 1, i));
end

% ML Detector (minimum Euclidean distance)


demod11 = demodulate(bpskdemod, r11.*conj(H(:, 1, 1)));
demod21 = demodulate(bpskdemod, z21);
demod12 = demodulate(bpskdemod, sum(z12, 2));

% Determine errors
error11(packetIdx) = biterr(demod11, data);
error21(packetIdx) = biterr(demod21, data);
error12(packetIdx) = biterr(demod12, data);
end % end of FOR loop for numPackets
% Calculate BER for current idx
% for uncoded 1x1 system
BER11(idx) = sum(error11)/(numPackets*frmLen);

% for G2 coded 2x1 system


BER21(idx) = sum(error21)/(numPackets*frmLen);

% for Maximal-ratio combined 1x2 system


BER12(idx) = sum(error12)/(numPackets*frmLen);

% for theoretical performance of second-order diversity


BERthy2(idx) = berfading(EbNo(idx), 'psk', 2, 2);

% Plot results
semilogy(EbNo(1:idx), BER11(1:idx), 'r*', ...
EbNo(1:idx), BER21(1:idx), 'go', ...
EbNo(1:idx), BER12(1:idx), 'bs', ...
EbNo(1:idx), BERthy2(1:idx), 'm');
legend('No Diversity (1Tx, 1Rx)', 'Alamouti (2Tx, 1Rx)',...
'Maximal-Ratio Combining (1Tx, 2Rx)', ...
'Theoretical 2nd-Order Diversity');

drawnow;
end % end of for loop for EbNo

% Perform curve fitting and replot the results


fitBER11 = berfit(EbNo, BER11);
fitBER21 = berfit(EbNo, BER21);
fitBER12 = berfit(EbNo, BER12);
semilogy(EbNo, fitBER11, 'r', EbNo, fitBER21, 'g', EbNo, fitBER12, 'b');
hold off;
The transmit diversity system has a computation complexity very similar to that of the receive
diversity system.
The resulting simulation results show that using two transmit antennas and one receive antenna
provides the same diversity order as the maximal-ratio combined (MRC) system of one transmit
antenna and two receive antennas.
Also observe that transmit diversity has a 3 dB disadvantage when compared to MRC receive
diversity. This is because we modelled the total transmitted power to be the same in both cases. If we
calibrate the transmitted power such that the received power for these two cases is the same, then the
performance would be identical. The theoretical performance of second-order diversity link matches
the transmit diversity system as it normalizes the total power across all the diversity branches.
The accompanying functional scripts, MRC1M.m and OSTBC2M.m aid further exploration for the
interested users.

PART 2: Space-Time Block Coding with Channel Estimation


Building on the theory of orthogonal designs, Tarokh et al. [2] generalized Alamouti's transmit
diversity scheme to an arbitrary number of transmitter antennas, leading to the concept of Space-Time
Block Codes. For complex signal constellations, they showed that Alamouti's scheme is the only full-
rate scheme for two transmit antennas.
In this section, we study the performance of such a scheme with two receive antennas (i.e., a 2x2
system) with and without channel estimation. In the realistic scenario where the channel state
information is not known at the receiver, this has to be extracted from the received signal. We assume
that the channel estimator performs this using orthogonal pilot signals that are prepended to every
packet [3]. It is assumed that the channel remains unchanged for the length of the packet (i.e., it
undergoes slow fading).
A simulation similar to the one described in the previous section is employed here, which leads us to
estimate the BER performance for a space-time block coded system using two transmit and two
receive antennas.
Again we start by defining the common simulation parameters
frmLen = 100; % frame length
maxNumErrs = 300; % maximum number of errors
maxNumPackets = 3000; % maximum number of packets
EbNo = 0:2:12; % Eb/No varying to 12 dB
N = 2; % number of Tx antennas
M = 2; % number of Rx antennas
pLen = 8; % number of pilot symbols per frame
W = hadamard(pLen);
pilots = W(:, 1:N); % orthogonal set per transmit antenna
and set up the simulation.
% Seed states for repeatability
seed = [98765 12345]; randn('state', seed(1)); rand('state', seed(2));

% Pre-allocate variables for speed


tx2 = zeros(frmLen, N); r = zeros(pLen + frmLen, M);
H = zeros(pLen + frmLen, N, M); H_e = zeros(frmLen, N, M);
z_e = zeros(frmLen, M); z1_e = zeros(frmLen/N, M); z2_e = z1_e;
z = z_e; z1 = z1_e; z2 = z2_e;
BER22_e = zeros(1, length(EbNo)); BER22 = BER22_e;
% Set up a figure for visualizing BER results
clf(h); grid on; hold on;
set(gca,'yscale','log','xlim',[EbNo(1), EbNo(end)],'ylim',[1e-5 1]);
xlabel('Eb/No (dB)'); ylabel('BER'); set(h,'NumberTitle','off');
set(h,'Name','Orthogonal Space-Time Block Coding');
set(h, 'renderer', 'zbuffer'); title('G2-coded 2x2 System');

% Loop over several EbNo points


for idx = 1:length(EbNo)
numPackets = 0; totNumErr22 = 0; totNumErr22_e = 0;

% Loop till the number of errors exceed 'maxNumErrs'


% or the maximum number of packets have been simulated
while (totNumErr22 < maxNumErrs) && (totNumErr22_e < maxNumErrs) && ...
(numPackets < maxNumPackets)
data = randint(frmLen, 1, P); % data vector per user per channel
tx = modulate(bpskmod, data); % BPSK modulation

% Alamouti Space-Time Block Encoder, G2, full rate


% G2 = [s1 s2; -s2* s1*]
s1 = tx(1:N:end); s2 = tx(2:N:end);
tx2(1:N:end, :) = [s1 s2];
tx2(2:N:end, :) = [-conj(s2) conj(s1)];

% Prepend pilot symbols for each frame


transmit = [pilots; tx2];

% Create the Rayleigh distributed channel response matrix


H(1, :, :) = (randn(N, M) + j*randn(N, M))/sqrt(2);
% assume held constant for the whole frame and pilot symbols
H = H(ones(pLen + frmLen, 1), :, :);

% Received signal for each Rx antenna


% with pilot symbols transmitted
for i = 1:M
% with normalized Tx power
r(:, i) = awgn(sum(H(:, :, i).*transmit, 2)/sqrt(N), EbNo(idx));
end

% Channel Estimation
% For each link => N*M estimates
for n = 1:N
H_e(1, n, :) = (r(1:pLen, :).' * pilots(:, n))./pLen;
end
% assume held constant for the whole frame
H_e = H_e(ones(frmLen, 1), :, :);

% Combiner using estimated channel


heidx = 1:N:length(H_e);
for i = 1:M
z1_e(:, i) = r(pLen+1:N:end, i).* conj(H_e(heidx, 1, i)) + ...
conj(r(pLen+2:N:end, i)).* H_e(heidx, 2, i);

z2_e(:, i) = r(pLen+1:N:end, i).* conj(H_e(heidx, 2, i)) - ...


conj(r(pLen+2:N:end, i)).* H_e(heidx, 1, i);
end
z_e(1:N:end, :) = z1_e; z_e(2:N:end, :) = z2_e;

% Combiner using known channel


hidx = pLen+1:N:length(H);
for i = 1:M
z1(:, i) = r(pLen+1:N:end, i).* conj(H(hidx, 1, i)) + ...
conj(r(pLen+2:N:end, i)).* H(hidx, 2, i);

z2(:, i) = r(pLen+1:N:end, i).* conj(H(hidx, 2, i)) - ...


conj(r(pLen+2:N:end, i)).* H(hidx, 1, i);
end
z(1:N:end, :) = z1; z(2:N:end, :) = z2;
% ML Detector (minimum Euclidean distance)
demod22_e = demodulate(bpskdemod, sum(z_e, 2)); % estimated
demod22 = demodulate(bpskdemod, sum(z, 2)); % known

% Determine errors
numPackets = numPackets + 1;
totNumErr22_e = totNumErr22_e + biterr(demod22_e, data);
totNumErr22 = totNumErr22 + biterr(demod22, data);
end % end of FOR loop for numPackets

% Calculate BER for current idx


% for estimated channel
BER22_e(idx) = totNumErr22_e/(numPackets*frmLen);

% for known channel


BER22(idx) = totNumErr22/(numPackets*frmLen);

% Plot results
semilogy(EbNo(1:idx), BER22_e(1:idx), 'ro');
semilogy(EbNo(1:idx), BER22(1:idx), 'g*');
legend(['Channel estimated with ' num2str(pLen) ' pilot symbols/frame'],...
'Known channel');
drawnow;
end % end of for loop for EbNo

% Perform curve fitting and replot the results


fitBER22_e = berfit(EbNo, BER22_e);
fitBER22 = berfit(EbNo, BER22);
semilogy(EbNo, fitBER22_e, 'r', EbNo, fitBER22, 'g'); hold off;
For the 2x2 simulated system, the diversity order is different than that seen for either 1x2 or 2x1
systems in the previous section.
Note that with 8 pilot symbols for each 100 symbols of data, channel estimation causes about a 1 dB
degradation in performance for the selected Eb/No range. This improves with an increase in the
number of pilot symbols per frame but adds to the overhead of the link. In this comparison, we keep
the transmitted SNR per symbol to be the same in both cases.
The accompanying functional script, OSTBC2M_E.m aids further experimentation for the interested
users.

PART 3: Orthogonal Space-Time Block Coding and Further Explorations


In this final section, we present some performance results for orthogonal space-time block coding
using four transmit antennas (4x1 system) using a half-rate code, G4, as per [4].
We expect the system to offer a diversity order of 4 and will compare it with 1x4 and 2x2 systems,
which have the same diversity order also. To allow for a fair comparison, we use quaternary PSK with
the half-rate G4 code to achieve the same transmission rate of 1 bit/sec/Hz.
Since these results take some time to generate, we load the results from a prior simulation. The
functional script OSTBC4M.m is included, which, along with MRC1M.m and OSTBC2M.m, was used
to generate these results. The user is urged to use these scripts as a starting point to study other codes
and systems.
load ostbcRes.mat;
% Set up a figure for visualizing BER results
clf(h); grid on; hold on; set(h, 'renderer', 'zbuffer');
set(gca, 'yscale', 'log', 'xlim', [EbNo(1), EbNo(end)], 'ylim', [1e-5 1]);
xlabel('Eb/No (dB)'); ylabel('BER'); set(h,'NumberTitle','off');
set(h,'Name','Orthogonal Space-Time Block Coding(2)');
title('G4-coded 4x1 System and Other Comparisons');

% Theoretical performance of fourth-order diversity for QPSK


BERthy4 = berfading(EbNo, 'psk', 4, 4);

% Plot results
semilogy(EbNo, ber11, 'r*', EbNo, ber41, 'ms', EbNo, ber22, 'c^', ...
EbNo, ber14, 'ko', EbNo, BERthy4, 'g');
legend('No Diversity (1Tx, 1Rx), BPSK', 'OSTBC (4Tx, 1Rx), QPSK', ...
'Alamouti (2Tx, 2Rx), BPSK', 'Maximal-Ratio Combining (1Tx, 4Rx), BPSK', ...
'Theoretical 4th-Order Diversity, QPSK');

% Perform curve fitting


fitBER11 = berfit(EbNo, ber11);
fitBER41 = berfit(EbNo(1:9), ber41(1:9));
fitBER22 = berfit(EbNo(1:8), ber22(1:8));
fitBER14 = berfit(EbNo(1:7), ber14(1:7));
semilogy(EbNo, fitBER11, 'r', EbNo(1:9), fitBER41, 'm', ...
EbNo(1:8), fitBER22, 'c', EbNo(1:7), fitBER14, 'k'); hold off;

You might also like