📄 demodulate.m
字号:
function y = demodulate(x, b, e, h, s2,s4,s16,s64,s256, c2,c4,c16,c64,c256);
% function y = demodulate(x, b, e, s2,s4,s16,s64,s256, c2,c4,c16,c64,c256);
%
% Finds minimum distance estimate of each received signal and returns the
% corresponding binary codeword. Use a Zero-Forcing approach for convenience
%
% y - modulated output, in the form of a row vector
% x - a vector of input symbols, for all the subcarriers (row vector)
% h - channel value (in frequency) for all subcarriers (64 elements)
% b - subcarrier bit allocation (64 elements in this matrix, each one
% corresponding to the number of bits to be allocated to the subcarrier
% having the same index)
% e - energy allocation (64 elements in this matrix)
% s_ - the encoder for a given constellation size
% c_ - the codewords as vectors of bits for the indices
y=[];
for i = 1:length(b)
switch b(i)
case {1}
[tmp, index] = min(abs(s2-1/h(i)/sqrt(e(i))*x(i)));
y = [y c2(index,:)];
case {2}
[tmp, index] = min(abs(s4-1/h(i)/sqrt(e(i))*x(i)));
y = [y c4(index,:)];
case {4}
[tmp, index] = min(abs(s16-1/h(i)/sqrt(e(i))*x(i)));
y = [y c16(index,:)];
case {6}
[tmp, index] = min(abs(s64-1/h(i)/sqrt(e(i))*x(i)));
y = [y c64(index,:)];
case {8}
[tmp, index] = min(abs(s256-1/h(i)/sqrt(e(i))*x(i)));
y = [y c256(index,:)];
otherwise
index = 0;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -