📄 qamdemod.m
字号:
%+----------------------------------------------------------------+
%| |
%| Name: qamdemod.m |
%| Author: Mathew Liu, James Shen |
%| Description: Takes in 'in_symbol' which can be noisy, ie |
%| it does not lie on the original constellation. We map it to |
%| the closest symbol in the constellation, find it's index in |
%| the QAM alphabet array and turn it back into a binary. |
%| |
%+----------------------------------------------------------------+
function[out_binary] = qamdemod(in_symbols, carrier_count, M)
%================ Generate QAM alphabet again =================
temp_M = -(M-1):2:(M-1); % Generate QAM Alphabet
for i=1:M
for k = 1:M
QAM(i,k) = temp_M(i) + j*temp_M(k);
end
end
QAM_alpha = QAM(:).';
%========= Map Symbol to Constellation and Dec2Bin ============
for row=1:carrier_count
[out_symbol, index] = closest(QAM_alpha, in_symbols(row));
index = index - 1;
% The index is always 1 more than the binary number since the
% index needs to start with one, where as the binary data can be 0.
% Decimal to Binary conversion
for bit_position = M:-1:1
if (index >= 2^(bit_position-1))
out_binary(row,bit_position) = 1;
index = index - 2^(bit_position-1);
else
out_binary(row,bit_position) = 0;
end
end
end
%====================== End File =================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -