gusucode.com > 多天线系统的各种信号检测算法matlab源码程序 > MIMO_detection/MLD_detection.m
function [MLD_det_bit]=MLD_detection(y,H,Tx,Modu_bit) %使|y-Hs|^2最小的s %considering Tx=4, and QPSK OneBySqrt2=0.7071067812; if Tx==4 & Modu_bit==2 %constitute all candidates for each antenna tmp=[-1,1]; cand=zeros(4,1); for a=1:2 for b=1:2 index=b+(a-1)*2; cand(index)=tmp(a)+j*tmp(b) cand(index)=cand(index)*OneBySqrt2; end end %initial s1_index_optimal=0;s2_index_optimal=0;s3_index_optimal=0;s4_index_optimal=0; min_err=9999999; for s1_index=1:4 s1_index; z1=y-H(:,1)*cand(s1_index); for s2_index=1:4 z2=z1-H(:,2)*cand(s2_index); for s3_index=1:4 z3=z2-H(:,3)*cand(s3_index); for s4_index=1:4 z4=z3-H(:,4)*cand(s4_index); err=z4'*z4;%向量模的平方等于各分量模的平方的和,而复数的模的平方等于该复数乘以它的共轭复数 if err<min_err min_err=err; s1_index_optimal=s1_index;s2_index_optimal=s2_index; s3_index_optimal=s3_index;s4_index_optimal=s4_index; end end end end end MLD_det_bit(1,:)=component_wise(cand(s1_index_optimal),Modu_bit); MLD_det_bit(2,:)=component_wise(cand(s2_index_optimal),Modu_bit); MLD_det_bit(3,:)=component_wise(cand(s3_index_optimal),Modu_bit); MLD_det_bit(4,:)=component_wise(cand(s4_index_optimal),Modu_bit); end %if Tx==4 %considering Tx=4, and 64QAM OneBySqrt42=0.1543033499; if Tx==4 & Modu_bit==6 %constitute all candidates for each antenna tmp=[-7,-5,-3,-1,1,3,5,7]; cand=zeros(64,1); for a=1:8 for b=1:8 index=b+(a-1)*8; cand(index)=tmp(a)+j*tmp(b); cand(index)=cand(index)*OneBySqrt42; end end %initial s1_index_optimal=0;s2_index_optimal=0;s3_index_optimal=0;s4_index_optimal=0; min_err=9999999; for s1_index=1:64 s1_index; z1=y-H(:,1)*cand(s1_index); for s2_index=1:64 z2=z1-H(:,2)*cand(s2_index); for s3_index=1:64 z3=z2-H(:,3)*cand(s3_index); for s4_index=1:64 z4=z3-H(:,4)*cand(s4_index); err=z4'*z4; if err<min_err min_err=err; s1_index_optimal=s1_index;s2_index_optimal=s2_index; s3_index_optimal=s3_index;s4_index_optimal=s4_index; end end end end end MLD_det_bit(1,:)=component_wise(cand(s1_index_optimal),Modu_bit); MLD_det_bit(2,:)=component_wise(cand(s2_index_optimal),Modu_bit); MLD_det_bit(3,:)=component_wise(cand(s3_index_optimal),Modu_bit); MLD_det_bit(4,:)=component_wise(cand(s4_index_optimal),Modu_bit); end %if Tx==4 return;