0% found this document useful (0 votes)
504 views

Maximal Ratio Combining Example in Matlab

Maximal ratio combining (MRC) is a technique for combining signals received across multiple antennas at a receiver. MRC weights each received signal by its signal-to-noise ratio (SNR) before combining. The SNR of the combined signal equals the sum of the SNRs of the individual signals, effectively improving reception. The document provides an example MRC implementation in MATLAB to demonstrate that the combined SNR is the sum of the individual SNRs when the noise is independent across channels.

Uploaded by

Angela Fasuyi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
504 views

Maximal Ratio Combining Example in Matlab

Maximal ratio combining (MRC) is a technique for combining signals received across multiple antennas at a receiver. MRC weights each received signal by its signal-to-noise ratio (SNR) before combining. The SNR of the combined signal equals the sum of the SNRs of the individual signals, effectively improving reception. The document provides an example MRC implementation in MATLAB to demonstrate that the combined SNR is the sum of the individual SNRs when the noise is independent across channels.

Uploaded by

Angela Fasuyi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Maximal Ratio Combining Example in

Matlab
In the old days, communication between a transmitter and receiver was
simple. The transmitter sent out a single signal through one antenna, which
eventually arrived at a single antenna at the receiver, probably along with a
little noise.

The Good Old Days


But we just couldnt be satisfied with that, could we? We got mad when our
cellphones dropped calls. We noticed, curiously, that we could often improve
reception during a call by just taking a couple steps in one direction, and
maybe turning 90 or 180 degrees. We began to start asking questions
Harry: What if we put 2, 3, I dunno, 8 antennas on the receiver separated
by a little space? Maybe by luck if the signal is arriving weakly at one
antenna, it might be arriving strongly at another?
Barry: Yeah, I like that! If its zigging at one antenna maybe its zagging at
another. We could just program the receiver to pick and use the strongest
signal.
Jerry: But what about the 7 other weaker signals? Theres real information
there and youre just going to throw it away? I say we average all the
signals!
Larry: Jerry, if youre eating a delicious lobster salad and I come along and
pour some brussel sprout pure all over it, what are you tasting now? Only
godawful brussel sprouts! Good information + bad information = bad
information. There must be some way to blend the signals SMARTLY

I was pondering this question back in the early 2000s. As luck would have
it, I attended a conference where many papers had to handle this very issue.
Only all the presenters seemed to know what the answer was, and it was
called maximal ratio combining (MRC).
Most of their papers briefly presented how to do it. Have a look!

B. Holter and G. Oien, The Optimal


Weights of a Maximum Ratio Combiner Using an Eigenfilter Approach,
Proc. 5th IEEE Nordic Signal Processing Symposium, Oct. 2002.
Now Im sure the Norwegians and everybody else who authored such papers
thought theyd made it all crystal clear. But when I see hieroglyphics like
this, my brain just shuts down. Theres only one thing for it and thats the
trusty old technique of Proof by Matlab. It goes like this.
1. Attempt to read IEEE paper. Stop in paragraph 3
unable to see through tears.
2. Open paper again. Try to just see what variables
they're working with and how (+, -, , )
3. Think, if I had these variables to work with,
what would I do? Might they be doing something like

that?
4. Try ideas for hours in Matlab. Eventually get
same performance as shown in paper.
And of course the work would be wasted if it we dont also doProfessional
Reputation Enhancement by Matlab. This involves first academifying your
code by replacing for-loops with matrix operations and trying to do as much
as possible on each single line via nested parentheses, then forwarding it and
a PDF of the paper on to the boss and colleagues describing the technique
as this simple idea I stumbled across that you quickly coded up and
yawn yeah, it works
Id like to think Im more mature now so let me just give you the quick
download on maximal ratio combining.
1. MRC is just a weighted average of the multiple
copies
2. The weight for each is the SNR of the channel it
came from
3. Not SNR in dB! Just plain ol' unitless SNR
4. The SNR of the resulting average is the sum of
all the channel SNRs
5. Not SNR in dB! Just plain ol' unitless SNR
For (4) to be true, the noise in each of the channels has to be independent. If
the noise is correlated well, Im sure theres a paper out there thatll show
you what to do, and I bet it involves some sinister autocovariance matrix (in
fact, that might be the R in the paper I sampled above).
While I wont touch that one with a 10 ft. pole, I will let you steal my code
for normal MRC below!

% Maximal Ratio Combining Example


% luminouslogic.com
% Goal: prove that by weighting multiple copies of a signal by each's SNR,
the result is
% a single signal whose SNR is the SUM of the individual copies
% Initialize workspace
clear all;
close all;
% Simulation parameters
snr_db_copies = [20 15 12];
num_iter
= 10000;

% The SNR in dB of each of the copies


% # of combines to perform

% Create BPSK signals


tx_symbols = round(rand(num_iter,1))*2 - 1;
% Define how much to scale the mu=0 s=1 noise to get desired SNRs
% Now, I know that SNR_dB = 10*log10( signal_var / noise_var)
% And by experimentation, I see that if noise created by randn is scaled by
K,
% the resulting variance of that noise is K^2. So,
% SNR_dB = 10*log10( signal_var / K^2)
% SNR_dB / 10 = log10( signal_var / K^2)
% 10^(SNR_dB / 10) = signal_var / K^2
% 10^(-SNR_dB/10) = K^2 / signal_var
% K^2 = signal_var * 10^(-SNR_dB/10)
% so use K = sqrt(signal_var * 10^(-SNR_dB/10)) to scale noise for desired
SNR
% Create channel noise
K
= sqrt( var(tx_symbols) * 10.^(-snr_db_copies/10));
noise = randn(num_iter, length(K)) .* K(ones(1, num_iter),:);
% Create received copies of noisy signals
rx_symbols = tx_symbols(:,ones(1,length(snr_db_copies))) + noise;
% Estimate SNR on each channel to verify coded up correctly
S = var(tx_symbols);
for i=1:length(snr_db_copies)
N = var(rx_symbols(:,i) - tx_symbols);
fprintf(1,'SNR on channel %d is supposed to be %2.0f dB.
is %2.2f dB\n',i,snr_db_copies(i),10*log10(S/N))
end

Actually

% Create Maximal Ratio Combining (MRC) weights


mrc_weights
= 10.^(snr_db_copies/10); % Weight by SNR (but not in dB!)
% Perform MRC
mrc_rx_symbols = rx_symbols * mrc_weights.' / sum(mrc_weights);

% Did it work? Well, isn't that something!


N = var(mrc_rx_symbols - tx_symbols);
fprintf(1,'SNR after MRC
is supposed to be %2.1f dB.
dB\n',10*log10(sum(mrc_weights)), 10*log10(S/N))

Actually is %2.2f

Maximal Ratio Combining (MRC)


by KRISHNA SANKAR on SEPTEMBER 28, 2008
This is the third post in the series discussing receiver diversity in a wireless link. Receiver
diversity is a form of space diversity, where there are multiple antennas at the receiver. The
presence of receiver diversity poses an interesting problem how do we use effectively the
information from all the antennas to demodulate the data. In the previous posts, we
discussedselection diversity and equal gain combining (EGC).
In this post, we will discuss Maximal Ratio Combining (MRC). For the discussion, we will
assume that the channel is a flat fading Rayleigh multipath channel and the modulation is BPSK.

Background
We use the same constraints as defined in the Selection Diversity and Equal Gain Combining
(EGC) post. Let me repeat the same.
1. We have N receive antennas and one transmit antenna.
2. The channel is flat fading In simple terms, it means that the multipath channel has only one
tap. So, the convolution operation reduces to a simple multiplication. For a more rigorous
discussion on flat fading and frequency selective fading, may I urge you to review Chapter 15.3
Signal Time-Spreading from [DIGITAL COMMUNICATIONS: SKLAR]
3. The channel experienced by each receive antenna is randomly varying in time. For the
receive antenna, each transmitted symbol gets multiplied by a randomly varying complex
number

. As the channel under consideration is a Rayleigh channel, the real and imaginary

parts of

are Gaussian distributed having mean

and variance

4. The channel experience by each receive antenna is independent from the channel
experienced by other receive antennas.
5. On each receive antenna, the noise

has the Gaussian probability density function with

with

and

The noise on each receive antenna is independent from the noise on the other receive antennas.
6. At each receive antenna, the channel
7. In the presence of channel
antenna is

is known at the receiver.

, the instantaneous bit energy to noise ratio at

. For notational convenience, let us define,

Maximal Ratio Combining (MRC)


On the

receive antenna, the received signal is,

where
is the received symbol on the
is the channel on the

receive antenna,

receive antenna,

is the transmitted symbol and


is the noise on

receive antenna.

Expressing it in matrix form, the received signal is,


, where

is the received symbol from all the receive antenna

is the channel on all the receive antenna


is the transmitted symbol and

is the noise on all the receive antenna.


The equalized symbol is,
.

receive

It is intuitive to note that the term,

i.e sum of the channel powers across all the receive antennas.
Note: The equations in the post refers the note on Receive diversity by Prof. RaviRaj Adve.

Effective Eb/No with Maximal Ratio


Combining (MRC)
Earlier, we noted that in the presence of channel
at

, the instantaneous bit energy to noise ratio

receive antenna is

.
Given that we are equalizing the channel with

, with the

receive antenna case, the

effective bit energy to noise ratio is,

.
Effective bit energy to noise ratio in a N receive antenna case is N times the bit energy to
noise ratio for single antenna case. Recall, this gain is same as the improvement which we got
in Receive diversity for AWGN case
Click here to download Matlab/Octave script for plotting effective SNR with Maximal Ratio
Combining in Rayleigh channel

Figure: Effective SNR with Maximal Ratio Combining in Rayleigh fading channel

Error rate with Maximal Ratio Combining


(MRC)
From the discussion on chi-square random variable, we know that, if
random variable, then
pdf of

is a Rayleigh distributed

is a chi-squared random variable with two degrees of freedom. The

is
.

Since the effective bit energy to noise ratio


of

is a chi-square random variable with

is the sum of

such random variables, the pdf

degrees of freedom. The pdf of

is,

.
If you recall, in the post on BER computation in AWGN, with bit energy to noise ratio of

, the

bit error rate for BPSK in AWGN is derived as


.
Given that the effective bit energy to noise ratio with maximal ratio combining is
error rate is the integral of the conditional BER integrated over all possible values of
.

, the total bit


.

This equation reduces to

, where

.
Refer Equation 11.12 and Equation 11.13 in Section 11.3.1 Performance with Maximal Ratio
Combining in [DIG-COMM-BARRY-LEE-MESSERSCHMITT]. Again, I do not know the proof

BER Simulation Model


The Matlab/Octave script performs the following
(a) Generate random binary sequence of +1s and -1s.
(b) Multiply the symbols with the channel and then add white Gaussian noise.
(c) Chose that receive path, equalize the received symbols per maximal ratio combining
(d) Perform hard decision decoding and count the bit errors

(e) Repeat for multiple values of

and plot the simulation and theoretical results.

Click here to download Matlab/Octave script for simulating BER for BPSK in Rayleigh channel
with Maximal Ratio Combining

Figure: BER plot for BPSK in Rayleigh channel with Maximal Ratio Combining
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% All rights reserved by Krishna Pillai, http://www.dsplog.com
% The file may not be re-distributed without explicit authorization
% from Krishna Pillai.
% Checked for proper operation with Octave Version 3.0.0
% Author
: Krishna Pillai
% Email
: [email protected]
% Version
: 1.0
% Date
: 28th September 2008
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Script for computing the SNR improvement in
% Rayleigh fading channel with Maximal Ratio Combining
clear
N = 10^3; % number of bits or symbols
% Transmitter
ip = rand(1,N)>0.5; % generating 0,1 with equal probability
s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0
nRx = [1:20];
Eb_N0_dB =
[25]; % multiple Eb/N0 values
for jj = 1:length(nRx)
for ii = 1:length(Eb_N0_dB)
n = 1/sqrt(2)*[randn(nRx(jj),N) + j*randn(nRx(jj),N)]; % white
gaussian noise, 0dB variance
h = 1/sqrt(2)*[randn(nRx(jj),N) + j*randn(nRx(jj),N)]; % Rayleigh
channel
% Channel and noise Noise addition
sD = kron(ones(nRx(jj),1),s);%sD = 1;
y = h.*sD + 10^(-Eb_N0_dB(ii)/20)*n;

% maximal ratio combining


yHat = sum(conj(h).*y,1);
% effective SNR
EbN0EffSim(ii,jj) = mean(abs(yHat));
EbN0EffThoery(ii,jj) = nRx(jj);
end
end
close all
figure
plot(nRx,10*log10(EbN0EffThoery),'bd-','LineWidth',2);
hold on
plot(nRx,10*log10(EbN0EffSim),'mp-','LineWidth',2);
axis([1 20 0 16])
grid on
legend('theory', 'sim');
xlabel('Number of receive antenna');
ylabel('SNR gain, dB');
title('SNR improvement with Maximal Ratio Combining');

You might also like