closest.m

来自「OFDM信道估计和均衡的仿真程序」· M 代码 · 共 20 行

M
20
字号
%+----------------------------------------------------------------+
%|                                                                |
%|  Name: closest.m                                               |
%|  Author: Mathew Liu, James Shen                                |
%|  Description: Takes in a QAM alphabet and a noisy_symbol and   |
%|  finds the closest match on the constellation. It also returns |
%|  the index of it inside the QAM alphabet array.                |
%|                                                                |
%+----------------------------------------------------------------+
function[out_symbol, index] = closest(QAM_alpha, noise_symbol)

for i=1:length(QAM_alpha)
   dist(i) = abs(QAM_alpha(i) - noise_symbol);
end

[val,index] = min(dist);

out_symbol = QAM_alpha(index);

%====================== End File =================================

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?