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

MRC误码率的matlab仿真相关推荐

  1. m扩频通信系统在瑞利信道中的误码率性能matlab仿真

    目录 1.算法描述 2.matlab算法仿真效果 3.MATLAB核心程序 4.完整MATLAB 1.算法描述 本课题,我们主要涉及到两个理论要点,第一个是瑞利衰落条件,第二个是扩频通信.下面分别对这 ...

  2. RS编码译码误码率性能matlab仿真

    目录 1.算法描述 2.仿真效果预览 3.MATLAB部分代码预览 4.完整MATLAB程序 1.算法描述 纠错编码技术在卫星通信.移动通信及数字存储等领域已获得了广泛的应用.RS码作为其中最重要的码 ...

  3. RS+BCH级联编译码误码率性能matlab仿真

    目录 1.算法描述 2.仿真效果预览 3.MATLAB部分代码预览 4.完整MATLAB程序 1.算法描述 在实际情况中,在光通信信道中出现的错误有单独随机出现的误码,也有突发出现的无码,为了更好的提 ...

  4. BCH编码译码误码率性能matlab仿真

    目录 1.算法描述 2.仿真效果预览 3.MATLAB部分代码预览 4.完整MATLAB程序 1.算法描述 BCH编译码是一种纠错能力强,构造简单的信道编译码.BCH编译码的生成多项式可以由如下的式子 ...

  5. turbo编译码误码率性能matlab仿真

    目录 1.算法描述 2.仿真效果预览 3.MATLAB部分代码预览 4.完整MATLAB程序 1.算法描述 Turbo码是一种极为复杂的信道编码技术,译码算法往往由于硬件实现的复杂度太高或者译码时延太 ...

  6. 【polar】协作polar码和非协作polar码的误码率性能matlab仿真

    1.软件版本 matlab2017b 2.本算法理论知识 <基于Polar码的协作编码和分集技术研究> 3.部分源码 clc; clear all; close all; warning ...

  7. MQAM调制在MIMO-OFDM通信系统的误码率性能matlab仿真

    目录 1.算法仿真效果 2.MATLAB源码 3.算法概述 4.部分参考文献 1.算法仿真效果 matlab2022a仿真结果如下: 2.MATLAB源码 % superpositi

  8. 16qam调制、接收、眼图、误码率曲线matlab仿真

    MQAM (Multiple Quadrature Amplitude Modulation) 多进制正交幅度调制.4相相位键控信号其实也是一种二电平正交振幅键控.如果将二电平振幅键控进一步发展为多电 ...

  9. msk误码率 matlab仿真,GMSK调制解调的MATLAB仿真与误码率分析.pdf

    GMSK调制解调的MATLAB仿真与误码率分析 67 第34卷 第2期 <新疆师范大学学报>(自然科学版) Vol.34,No.2 2015年6月 Journal of Xinjiang ...

最新文章

  1. 浏览器对象模型:window对象2
  2. Event 系列: jquery event 源码
  3. 宣布 Windows Azure 通过 PCI DSS 合规性验证并且 ISO 认证范围扩大,同时正式发布 Windows Azure Hyper-V 恢复管理器和其他更新功能...
  4. [luoguP1640] [SCOI2010]连续攻击游戏(二分图最大匹配)
  5. html中属性idx区别,HTML 中的name属性和id属性有什么区别?
  6. iOS开发UI篇—CAlayer(创建图层)
  7. java通过url抓取网页数据-----正则表达式
  8. php获取错误信息函数,关于php:如何获取mail()函数的错误消息?
  9. 项目启动居然如此重要!
  10. Java-异常03 自定义异常
  11. python finally语句里面出现异常_Python异常处理中的else和finally
  12. Spring Boot配置文件application.properties
  13. MVC5+EF6--1 创建Entity Framework数据模型
  14. Python开发环境配置 Vim + Ctags+ TagList
  15. html在ie中img地址为https,关于IE10以下的img标签问题解决
  16. 思维导图让你掌握《有效沟通》
  17. Vs2010 Qt插件安装教程
  18. linux 实现离线迅雷,Linux 下使用 wget/aria2 进行离线迅雷批量下载
  19. MCS51 程序存储器(ROM)
  20. 51单片机码表c语言编程,分享自写码表单片机程序(共阴极数码管显示)

热门文章

  1. 为什么说测试岗位是巨坑?10年测试人告诉你千万别上当
  2. 用c语言做学生公寓管理系统,基于C/S结构的学生公寓管理系统
  3. 100.8元该怎么花,笨拙的人从来不会思考这个问题
  4. u盘恢复数据|U盘打不开提示格式化怎么恢复数据?
  5. 2022年5月20日最全摸鱼游戏导航
  6. android自学视频!2021年Android进阶者的新篇章,附面试题答案
  7. context是什么意思
  8. 数据结构之二叉树基本操作
  9. 【分块】铃铛计数问题
  10. 计算机专业自我总结100字,计算机专业学生自我评价100字