gusucode.com > 多天线系统的各种信号检测算法matlab源码程序 > MIMO_detection/main_sub.m
function main_sub(corr_amp,EbNo,LoopN) %%%%%%%%%%%%%%%%% %Define some parameters Tx=4; % number of transmit antenna Rx=4; % number of receive antenna Modu_size=4; %4->QPSK,16->16QAM,64->64QAM Modu_bit=2; %2->QPSK,4->16QAM,6->64QAM frame_length=48; %corr_amp=0.85; %correlation amplitude corr_phase=60; %the phase of the complex value, r, (degrees) %EbNo=25; %dB %LoopN=10; %%%%%%%%%%%%%%%% SNR=EbNo+3*Modu_bit/2; %dB SNR=SNR-10*log10(Tx); %dB ZF_err_num=0; MLD_err_num=0; MMSE_err_num=0; QR_err_num=0; ZF_IC_err_num=0; %printf the corr_map EbNo & loop to know the process of the program's running fid = fopen('track.txt','a'); fprintf(fid,'corr_amp: %f, EbNo: %d, LoopN is: %d\n',corr_amp,EbNo,LoopN); fclose(fid); for loop=1:LoopN %loop; fid = fopen('track.txt','a'); fprintf(fid,'loop: %d\n',loop); fclose(fid); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%initial%%%%%%%%%%%%%%%%%%%%%%%%%%%% trans_bit=zeros(Tx,Modu_bit); trans_sig=zeros(Tx,frame_length); %transmited signal H=zeros(Rx,Tx); %channel matrix noise=zeros(Rx,frame_length); y=zeros(Rx,frame_length); %received signal %以下要不要变???? ZF_det_bit=zeros(Tx,Modu_bit*frame_length); %ZF detection result % % MLD_det_bit=zeros(Tx,Modu_bit); %MLD detection result % MMSE_det_bit=zeros(Tx,Modu_bit); %MMSE detection result % QR_det_bit=zeros(Tx,Modu_bit); % ZF_IC_det_bit=zeros(Tx,Modu_bit); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%transmitor%%%%%%%%%%%%%%%%%%%%%%%%%% trans_bit=encoder(Tx,Modu_bit*frame_length);%transmit only one symbol %(but the symbol on every transmitted antenna is different) trans_sig=QAMmodu(trans_bit,Tx,Modu_bit); %%%%%%%%%%transmit through multipath channel and affect by AWGN%%%%%%%% H=channel_generator(Rx,Tx,corr_amp,corr_phase); %generate the correlated channel noise=noise_generator(Rx,SNR,frame_length); y=H*trans_sig+noise; %MIMO model, trans_sig*sqrt(42) is the 64QAM %y=H*trans_sig; %for test of no noise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%receiver%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ZF_det_bit=ZF_detection(y,H,Tx,Modu_bit); %using y, and H to detect signals tmp1_err=err_count(trans_bit,ZF_det_bit,Tx,Modu_bit); ZF_err_num=ZF_err_num+tmp1_err; % MMSE_det_bit=MMSE_detection(y,H,Tx,Modu_bit,SNR); % tmp3_err=err_count(trans_bit,MMSE_det_bit,Tx,Modu_bit); % MMSE_err_num=MMSE_err_num+tmp3_err; % QR_det_bit=QR_detection(y,H,Tx,Modu_bit); % tmp3_err=err_count(trans_bit,QR_det_bit,Tx,Modu_bit); % QR_err_num=QR_err_num+tmp3_err; % ZF_IC_det_bit=ZF_IC_detection(y,H,Tx,Modu_bit) % tmp4_err=err_count(trans_bit,ZF_IC_det_bit,Tx,Modu_bit); % ZF_IC_err_num=ZF_IC_err_num+tmp4_err; %this is the actual MLD, but its speed is too slow %tic; %MLD_det_bit=MLD_detection(y,H,Tx,Modu_bit); %using y, and H to detect %toc; %%%%the following program needs to been read carefully again! % tic; % MLD_det_bit=Appro_MLD_detection(y,H,Tx,Modu_bit,SNR); %using y, and H to detect signals % toc; %MLD_det_bit=fast_MLD(y,H,Tx,Modu_bit,SNR,trans_bit); %using y, and H to detect signals % tmp2_err=err_count(trans_bit,MLD_det_bit,Tx,Modu_bit); % MLD_err_num=MLD_err_num+tmp2_err; end %end loop %ZF_err_num/LoopN/Tx/Modu_bit; %MMSE_err_num/LoopN/Tx/Modu_bit; %MLD_err_num/LoopN/Tx/Modu_bit; fid = fopen('result.txt','a'); fprintf(fid,'corr_amp: %f, EbNo: %d, ZF BER is: %f\n',corr_amp,EbNo,ZF_err_num/LoopN/Tx/Modu_bit/frame_length); %fprintf(fid,'corr_amp: %f, EbNo: %d, MMSE BER is: %f\n',corr_amp,EbNo,MMSE_err_num/LoopN/Tx/Modu_bit); %fprintf(fid,'corr_amp: %f, EbNo: %d, QR BER is: %f\n',corr_amp,EbNo,QR_err_num/LoopN/Tx/Modu_bit); % fprintf(fid,'corr_amp: %f, EbNo: %d, ZF_IC_BER is: %f\n',corr_amp,EbNo,ZF_IC_err_num/LoopN/Tx/Modu_bit); %fprintf(fid,'corr_amp: %f, EbNo: %d,Appro_MLD BER is: %f\n',corr_amp,EbNo,MLD_err_num/LoopN/Tx/Modu_bit); fclose(fid);