MRC误码率的matlab仿真
1.问题描述:
MRC误码率的matlab仿真
2.部分程序:
%Comparison of Decode and F,Detect and F and Amplify and Forward
%BPSK in flat fading with WGN:
%plot simulation results of BER and theoratical results for it.
%combining the two signals using MRC
%using averaged BER
%%%%%%%%%house hold instuctions%%%%%%%%%%%%%%%%%%
clc
clear all
close all
sum_dcf = 0;
sum_dtf = 0;
sum_af = 0;
%%%%%%%%%%%%%%%%%%%User1:Source%%%%%%%%%%%%%%
N_bits = 15000; %Number of data bits
%number of iterations over which the results are going to be averaged
N_iter = 15;
for iter = 1:N_iter
data = round(rand(N_bits,1));%random data bits
%channel coding using rate 1/2 convolutional code:
trellis = poly2trellis(3,[5 7]); %trellis structure
c_data = convenc(data,trellis);
%BPSK modulation
tx = 2*c_data - 1;
%%%%%%%%%Channel characteristics%%%%%%%%%%%%%%%%
SNRdB = -3:20; %Range of SNR for which BER is investigated.
%additive noise and channel response for the relay channel:
%Source uplink channel:
noise_d = 1/sqrt(2) * (randn(2 * N_bits,1) + j * randn(2 * N_bits,1));
h_d = 1/sqrt(2) * (randn(2 * N_bits,1) + j * randn(2 * N_bits,1));
%interuser channel:
noise_r1 = 1/sqrt(2) * (randn(2 * N_bits,1) + j * randn(2 * N_bits,1));
h_r1 = 1/sqrt(2) * (randn(2 * N_bits,1) + j * randn(2 * N_bits,1));
%for Relay uplink:
noise_r2 = 1/sqrt(2) * (randn(2 * N_bits,1) + j * randn(2 * N_bits,1));
h_r2 = 1/sqrt(2) * (randn(2 * N_bits,1) + j * randn(2 * N_bits,1));
for k = 1:length(SNRdB)
SNR = 10^(SNRdB(k)/10); %convert SNRdB to linear value SNR
ftx_r1 = sqrt(SNR) * h_r1 .* tx + noise_r1;
%%%%%%%%%%%%%%%%% At the Relay %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%Decode n F%%%%%%
%equalizing at relay
eq_rx1 = ftx_r1 .* conj(h_r1);
%hard decision and converting from bipolar to bits
r_bits = (sign(real(eq_rx1)) + 1)/2;
%channel decoding:
dec_dcf_r1 = vitdec(r_bits,trellis,3,'term','hard');
%re-encoding using the same procedure as Source:
c_data2 = convenc(dec_dcf_r1,trellis);
%BPSK signal for the relay coded data:
tx2_dcf = 2 * c_data2 - 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%Detect n F%%%
dec_dtf_r1 = sign(real(eq_rx1));
tx2_dtf = dec_dtf_r1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Apmlify n F%%
beta = sqrt(1./((SNR * abs(h_r1).^2) + 1));
%amplification:
ftx_amp = ftx_r1 .* beta;
%%%%%%%%%%%%%%%%%%%%%%%%%%Relay to Destination%
%DCF
ftx_dcf_r2 = sqrt(SNR) * tx2_dcf .* h_r2 + noise_r2 ;
%DTF
ftx_dtf_r2 = sqrt(SNR) * tx2_dtf .* h_r2 + noise_r2 ;
%AF
ftx_af_r2 = sqrt(SNR) * ftx_amp .* h_r2 + noise_r2 ;
%%%%%%%%%%%%%%%%% At the Destination%%%%%%%%%%%
ftx_d = sqrt(SNR)* tx .* h_d + noise_d;
%%%%%%%%%%%%%%%%%%%%%%%%DCF%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%MRC%%%%%%%%%%%%%%%
R_dcf = ftx_dcf_r2 .* conj(h_r2) + ftx_d .* conj(h_d);
%hard decisioning
dec_com_dcf = sign(real(R_dcf));
%%%%%%%%%%%BER calculations%%%%%%%%%%%%%%%%%%
%at destination:
err_com1(k) = sum(abs(dec_com_dcf - tx)/2);
simber_com1(k) = err_com1(k) / (2 * N_bits);
%%%%%%%%%%%%%%%%%%%%%%%%DTF%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%MRC%%%%%%%%%%%%%%%
R_dtf = ftx_dtf_r2 .* conj(h_r2) + ftx_d .* conj(h_d);
%hard decision
dec_com_dtf = sign(real(R_dtf));
%%%%%%%%%%%BER calculations%%%%%%%%%%%%%%%%%%
%at destination:
err_com2(k) = sum(abs(dec_com_dtf - tx)/2);
simber_com2(k) = err_com2(k) / (2 * N_bits);
%%%%%%%%%%%%%%%%%%%%%%%%AF%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%MRC%%%%%%%%%%%%%%%
R_af = ftx_af_r2 .* conj(h_r2) .* conj(h_r1) + ftx_d .* conj(h_d);
dec_com_af = sign(real(R_af));
%%%%%%%%%%%BER calculations%%%%%%%%%%%%%%%%%%
%at destination:
err_com3(k) = sum(abs(dec_com_af - tx)/2);
simber_com3(k) = err_com3(k) / (2 * N_bits);
theberawgn(k) = 0.5 * erfc (sqrt(SNR));%theoratical BER for AWGN
theberrayleigh(k) = 0.5 * (1 - sqrt(SNR./(1 + SNR))); %theoratical rayleigh
mue = sqrt(SNR/(1+SNR));
mrcth(k) = 0.25 * (2 + mue) * (1-mue)^2;%theoratical 2Rx MRC
end
sum_dcf = sum_dcf + simber_com1;
sum_dtf = sum_dtf + simber_com2;
sum_af = sum_af + simber_com3;
end
%average BER:
avgber_dcf = sum_dcf/N_iter;
avgber_dtf = sum_dtf/N_iter;
avgber_af = sum_af/N_iter;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%BER plots%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure
semilogy(SNRdB,avgber_dcf,SNRdB,avgber_dtf,SNRdB,avgber_af,SNRdB,theberawgn,SNRdB,theberrayleigh,SNRdB,mrcth);
axis([SNRdB(1) max(SNRdB) 10^-5 0.5]);
grid on
legend('DCF','DTF','AF','AWGN','Rayleigh','MRC 2 senders');
xlabel('SNR dB');
ylabel('BER');
title(['BER curves for comparison,(averaged for ',num2str(N_iter),' iterations)']);
3.仿真结论:
D69
相关文章
- MIMO系统Vblast检测算法误码率matlab仿真,对比了zf,mmse,mmse-sic,zf-sic,osic
- MFSK调制方式的频谱效率,误码率,频谱等matlab仿真
- 基于OFDM调制解调通信系统的频偏估计和采样时钟估计matlab仿真
- 基于MATLAB的ASK,FSK,PSK误码率对比仿真,输出调制后波形以及误码率曲线
- m瑞利信道下对比ZF-SIC,MMSE-SIC,MRC三种均衡算法的误码率matlab仿真
- m基于RFID和DBSCAN聚类的InSAR室内三维定位算法的matlab仿真
- m基于RBF神经网络和BP神经网络的信道估计误码率matlab仿真
- m基于机器学习MLP的OFDM信道估计误码率matlab仿真,对比LS和MMSE两种信道估计算法
- 通过matlab对比不同调制方式下的球形译码误码率仿真,包括BPSK,QPSK,8PSK,4QAM以及16QAM
- 基于PSO三维极点搜索matlab仿真
- m基于LPF-VMD和KELM的鸟群优化算法的风速预测算法matlab仿真
- m云计算任务调度优化matlab仿真,输出成本,时间,负荷优化结果,对比ACO,PSO,WOA三种优化算法
- 基于形态学处理算法的迷宫路线搜索matlab仿真
- lorenz混沌序列输出的matlab仿真
- m基于钱搜索算法的BCH编译码matlab仿真,仿真输出误码率曲线和编码增益曲线
- m规则LDPC和非规则LDPC误码率matlab对比仿真,并对比不同译码迭代次数的误码率
- 基于64QAM调制解调的LDPC编译码算法误码率matlab仿真
- RS+BCH级联编译码误码率性能matlab仿真
- 基于Astar算法的智能避障最短路径搜索matlab仿真,可以任意选择起点和终点
- 基于二维切片图序列的三维立体建模MATLAB仿真
- Matlab使用笔记(七):将PreScan连接MATLAB实现仿真 (附录:自动无人驾驶仿真软件PreScan的应用介绍)