How to use comm.SphereDecoding for a custom channel?

9 views (last 30 days)
Hi,
Currently, I am learning about MIMO systems. I want to use the comm.SphereDecoding function to decode a signal that has passed through a channel with a given channel matrix, H.
Everything I did was the same as the documentation, only I didn't use the comm.MIMOChannel function:
%%
% Pass the modulated data through the MIMO fading channel and add AWGN.
% [fadedSig,pathGains] = mimo(modData); % comm.MIMOChannel
% rxSig = awgnChan(fadedSig);
% Generate random channel matrix H
Nt = 2; % Number of transmit antennas
Nr = 2; % Number of receive antennas
H = randn(Nr, Nt) + 1i * randn(Nr, Nt);
rxSig = H*modData;
%% Decode
% decodedData = sphDec(rxSig,squeeze(pathGains));
decodedData = sphDec(rxSig, ???); % WHAT VALUE SHOULD I PUT IN "???"
My question is what value should I put in "???". I tried putting H in but got the error:
Error using comm.SphereDecoder/validateInputsImpl (line 217)
The number of receive antennas of CHAN [: Nt Nr] must be the same as the number of receive antennas of RXSYMBOLS [:
Nr].
Any answers are appreciated. Thanks.

Accepted Answer

Sudarsanan A K
Sudarsanan A K on 3 May 2024
Hello,
Seems like your intention is to bypass the "comm.MIMOChannel" with a channel matrix, , in the simulation of decoding by using the "comm.SphereDecoding" System Object. The "comm.SphereDecoding" expects the input arguments to be in the form (rxSig, pathgains) where, "rxSig" is the faded signal received after being passed through the channel, and "pathgains" is the squeezed version of the output path gains, returned as an array from the "comm.MIMOChannel".
  • is the number of samples.
  • is the number of discrete path delays specified by the "PathDelays" property of the "comm.MIMOChannel".
  • is the number of transmit antennas.
  • is the number of receive antennas.
However, when you're using a static matrix, , to represent the channel, you're effectively modeling a scenario with a single path () between each pair of transmit and receive antennas without considering the time-varying nature of the channel or multiple path delays. So, the sqeezing operation by "squeeze" returns an array with this singleton dimension removed. i.e., it results in an array of output path gains having a dimension .
Given this understanding, you can use the "comm.SphereDecoding" with a channel matrix, , as follows:
% Define the modulation order, number of transmitted bits, Eb/No ratio, and symbol mapping
bps = 4; % Bits per symbol
M = 2^bps; % Modulation order
nBits = 1e3*bps;
ebno = 1;
symMap = [11 10 14 15 9 8 12 13 1 0 4 5 3 2 6 7];
% Generate and display the symbol mapping
sym = qammod(symMap(1:M)', M, symMap, 'UnitAveragePower', true);
% Convert the symbol map to a binary bit table
bitTable = int2bit(symMap, bps)';
% Set the global random number generator seed for repeatability
rng(37);
% Generate a random data stream
data = randi([0 1], nBits, 1);
% Modulate the data and reshape it into two streams for the 2x2 MIMO channel
modData = qammod(data, M, symMap, 'InputType', 'bit', 'UnitAveragePower', true);
modData = reshape(modData, [], 2);
% Define a 2x2 MIMO Channel matrix H
H = randn(2, 2) + 1i * randn(2, 2);
% Apply the channel effects
rxSig = H * modData';
% Create an AWGN Channel System object
awgnChan = comm.AWGNChannel('EbNo', ebno, 'BitsPerSymbol', bps);
% Add AWGN to the received signal
rxSig = awgnChan(rxSig);
% Create a Sphere Decoder System object for decoding
sphDec = comm.SphereDecoder('Constellation', sym, 'BitTable', bitTable, 'DecisionType', 'Hard');
% Parameters remain the same
NS = size(rxSig, 2); % Number of samples
NP = 1; % Number of paths
NT = 2; % Number of transmit antennas
NR = 2; % Number of receive antennas
% Replicate H' across the samples dimension (1st dimension)
% Note: repmat is used to replicate H' across NS samples. Since H is 2x2, H' will also be 2x2,
% and we're replicating it NS times along the first dimension to match the expected dimensions for pathgains.
pathgains = repmat(permute(H', [3, 4, 1, 2]), NS, 1, 1, 1);
% Decode the received signal using the Sphere Decoder
decodedData = sphDec(rxSig', squeeze(pathgains));
% Convert the decoded data into a double column vector and calculate error statistics
dataOut = double(decodedData(:));
berRate = comm.ErrorRate;
errorStats = berRate(data, dataOut);
% Display the bit error rate and the number of errors
disp(['Bit Error Rate: ', num2str(errorStats(1))]);
Bit Error Rate: 0.02
disp(['Number of Errors: ', num2str(errorStats(2))]);
Number of Errors: 80
However, please note that here we directly use the known channel matrix () for creating "pathgains" without explicitly estimating it from "rxSig" and "modData". In practical scenarios, the receiver would estimate () from the received signal using known pilot symbols or training sequences. This approach assumes perfect channel knowledge at the receiver, which simplifies the decoding but is idealized.
I hope this helps!
  1 Comment
An
An on 9 May 2024
Sorry for the late reply.
Btw, I tried it and it worked. Thanks for your clear explanation.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!