资源简介
用matlab实现在瑞利信道条件下协作中继放大转发。
代码片段和文件信息
clear all;
Monte_MAX=10^(5);
%the length set of data frame
M=[1101001000];
MIN_SNR=0;
MAX_SNR=30;
INTEVAL=2;
POW_DIV=1/2;
%/fid=fopen(‘record.txt‘‘w‘);
%fprintf(fid‘%%%s\n‘datestr(now));
%close(fid);
%sr_distance=[0.10.50.70.9];
sd_distance=1;
rd_distance=1;
sr_distance=1;
for M_INDEX=1:4
%the length of data frame
M2=M(M_INDEX);
count=0;
for SNR=MIN_SNR:INTEVAL:MAX_SNR
sig=10^(SNR/10);
count=count+1;
%just display something on the screen.
datestr(now)
M2
SNR
err_num_dsd=0;
err_num_coop=0;
for tries=0:Monte_MAX
%generate the source BPSK signal 01
X1=rand(1M2)>0.5;
%generate the source BPSK signal+1-1
Xs=X1*2-1;
%the transmitted signal
Xst=sqrt(POW_DIV*sig)*Xs; %%%%??????
%generate the source-relay channel the channel is varied each bit
CH_sr=xy_RayleighCH(1)/(sr_distance)^2;
%the received signal of coop source-relay transmission
R_dsr=CH_sr*Xst+xy_noise(M2); %中继协作节点接收到的信号
%关键点之一:放大系数的选择
%the amplified signal of relay to destination
amp_coff=sqrt(POW_DIV*sig/(1+POW_DIV*sig*CH_sr*conj(CH_sr)));
Xr=R_dsr*amp_coff; %中继转发的信号
%the real ber just for test
%cBER=sum(Xs~=Xr)/M2;
%if (sum(Xs~=Xr)>0) tx_coop=0; end
tx_coop=1;
%generate the source-destination channel
CH_sd=xy_RayleighCH(1)/(sd_distance)^2;
%the received signal of direct source-destination transmission
R_dsd=CH_sd*sqrt(sig).*Xs+xy_noise(M2);%源节点直传到目的节点的信号, %%%%??????
%the decode signal of direct source-destination transmission
Y_dsd=(conj(CH_sd)*sqrt(sig).*R_dsd>0)*2-1;%对直传接收信号译码
%the received signal of cooperative source-destination transmission
R_csd=CH_sd*Xst+xy_noise(M2);
%generate the relay-destination channel the channel is varied each bit
CH_rd=xy_RayleighCH(1)/(rd_distance)^2;
%the received signal of cooperative relay-destination transmission
R_crd=CH_rd*Xr+xy_noise(M2);
%关键点之二:合并时候的噪声功率归一化处理 MRC最大比合并
R_combine=conj(CH_sd)*sqrt(POW_DIV*sig)*R_csd+amp_coff*sqrt(POW_DIV*sig)...
*conj(CH_sr)*conj(CH_rd).*R_crd/(1+amp_coff^2*conj(CH_rd)*CH_rd);
%the decode signal of cooperative MRC combining
Y_combine=(R_combine>0)*2-1;
%the number of packet error rate if one bit is different then the packet is discarded
if sum(Xs~=Y_dsd)>0
err_num_d
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4480 2012-10-17 17:26 AF.m
文件 67 2012-10-17 17:26 xy_noise.m
文件 75 2012-10-17 17:26 xy_RayleighCH.m
----------- --------- ---------- ----- ----
4622 3
- 上一篇:非线性模型预测控制的matlab参考代码
- 下一篇:一维喷管流动
评论
共有 条评论