function error_rate=kechengsheji(n,SNR,N_Receiver)
%______________________信源部分________________________%
c_source=rand(n,1);
c_source(c_source==1)=[];%剔除1,强制[0,0.5)和[0.5,1)等概率
c_source(c_source<0.5)=-1;%等概率前提近似取等号,免去信源编码;双极性。
c_source(c_source>=0.5)=1;
n_deng=length(c_source);%重新数出个数
if mod(n_deng,2) ~= 0
c_source(1)=[];
n_deng=n_deng-1;%强制c_source为偶数个
end
c_element=c_source;
c_length=n_deng;%结构体c储存
%
%不进行信道编码,防止对误码性能产生影响
%
%_____________________________________________________%
%____________________QPSK调制_________________________%
%B_map=[1+1i 1-1i -1-1i -1+1i];%%%%B方式调制
n_phase=c_length/2;
c_IQ=reshape(c_element,n_phase,2);%串并转换
c_phase=((c_IQ(:,1)*1i)+(c_IQ(:,2)));%相位映射
%scatterplot(c_phase)
B_jugle=[[1+1i;1+1i],[1+1i;1-1i],[1+1i;-1-1i],[1+1i;-1+1i], ...
[1-1i;1+1i],[1-1i;1-1i],[1-1i;-1-1i],[1-1i;-1+1i], ...
[-1-1i;1+1i],[-1-1i;1-1i],[-1-1i;-1-1i],[-1-1i;-1+1i], ...
[-1+1i;1+1i],[-1+1i;1-1i],[-1+1i;-1-1i],[-1+1i;-1+1i]];
%_____________________________________________________%
%____________________天线发射_________________________%
n_antenna=2;%发射天线数目为二
n_each_antenna=n_phase/n_antenna;
antenna=reshape(c_phase,n_each_antenna,n_antenna);
c_STBC = cell(n_each_antenna,1);%预设大小
%X=cell(n_each_antenna,1);
for i=1:n_each_antenna
c_STBC{i}=[antenna(i,:);[-1*conj(antenna(i,2)),conj(antenna(i,1))]];
%X{i}=antenna(i,:)';
end
%_____________________________________________________%
%______________________分集合并_MRC合并_____________________%
R_comphase_s=zeros(2*n_each_antenna,1);
% Alpha_s=zeros(n_each_antenna,N_Receiver);
H_comphase_s=zeros(2*n_each_antenna,2);
for k=1:N_Receiver
[R_comphase,H_comphase]=pass_rei(n_each_antenna,c_STBC,SNR);
R_comphase_s=R_comphase_s+R_comphase;
% Alpha_s(:,k)=alpha;
H_comphase_s(:,1)=H_comphase_s(:,1)+H_comphase(:,1);
H_comphase_s(:,2)=H_comphase_s(:,2)+H_comphase(:,2);
end
R=cell(n_each_antenna,1);
H=cell(n_each_antenna,1);
for i=1:n_each_antenna
odd=2*i-1;
even=2*i;
R{i}= [R_comphase_s(odd);R_comphase_s(even)];
H{i}= [H_comphase_s(odd,:);H_comphase_s(even,:)];
end
% for i=1:n_each_antenna
% R{i}= [R_comphase_s(2*i-1,:)*Alpha_s(i,:)';conj(R_comphase_s(2*i,:)*Alpha_s(i,:))']/sum(Alpha_s(i,:));
% for k=1:N_Receiver
% H{i}(1,:)=H_comphase_s
% end
% end
%_____________________________________________________%
%_________________________判决________________________%
x=zeros(n_each_antenna,2);%定义大小
for i=1:n_each_antenna
jugle=[norm(R{i}-H{i}*[1+1i;1+1i]),norm(R{i}-H{i}*[1+1i;1-1i]),norm(R{i}-H{i}*[1+1i;-1-1i]),norm(R{i}-H{i}*[1+1i;-1+1i]), ...
norm(R{i}-H{i}*[1-1i;1+1i]),norm(R{i}-H{i}*[1-1i;1-1i]),norm(R{i}-H{i}*[1-1i;-1-1i]),norm(R{i}-H{i}*[1-1i;-1+1i]), ...
norm(R{i}-H{i}*[-1-1i;1+1i]),norm(R{i}-H{i}*[-1-1i;1-1i]),norm(R{i}-H{i}*[-1-1i;-1-1i]),norm(R{i}-H{i}*[-1-1i;-1+1i]), ...
norm(R{i}-H{i}*[-1+1i;1+1i]),norm(R{i}-H{i}*[-1+1i;1-1i]),norm(R{i}-H{i}*[-1+1i;-1-1i]),norm(R{i}-H{i}*[-1+1i;-1+1i])];
x(i,:)=B_jugle(:,jugle==min(jugle))';%%%按书本方式解调
end
x=reshape(x,1,n_phase)';
x_comp=x-c_phase;
x_comp(x_comp~=0)=1;
error_rate=sum(x_comp)/n_phase;%误码率
%_____________________________________________________%
end
function [R_comphase,H_comphase]=pass_rei(n_each_antenna,c_STBC,SNR)
%____________________过瑞利信道_______________________%
%%r=cell(n_each_antenna,1);
%%H=cell(n_each_antenna,1);
n_each_antenna_c2=n_each_antenna*2;
H_comphase=zeros(n_each_antenna_c2,2);
%%R=cell(n_each_antenna,1);
Noise=zeros(n_each_antenna_c2,1);
R_comphase_nn=zeros(n_each_antenna_c2,1);%
R_comphase=zeros(n_each_antenna_c2,1);
P_noise=zeros(n_each_antenna_c2,1);
alpha=zeros(n_each_antenna_c2,1);
for i=1:n_each_antenna
odd=2*i-1;
even=2*i;
chan_1=rayleighchan; %scatterplot(r_rayleigh)
chan_2=rayleighchan;
%%h=[chan_1.PathGains;chan_2.PathGains];
h_comphase=[norm(chan_1.PathGains);norm(chan_2.PathGains)];%同相
%%r{i}=c_STBC{i}*h;
%%H{i}=[chan_1.PathGains,chan_2.PathGains;conj(chan_2.PathGains),-conj(chan_1.PathGains)];
%%R{i}=[awgn(r{i}(1),SNR);conj(awgn(r{i}(2),SNR))]; %scatterplot(r_pro)
%%Noise{i}= [R{i}(1);conj(R{i}(2))]- r{i};
%%R_comphase(2*i-1)=c_STBC{i}(1,:)*h_comphase+Noise{i}(1);
%%R_comphase(2*i)=conj(c_STBC{i}(2,:)*h_comphase+Noise{i}(2));
R_comphase_nn(odd)=c_STBC{i}(1,:)*h_comphase;%
R_comphase_nn(even)=c_STBC{i}(2,:)*h_comphase;%
R_comphase(odd)=awgn(R_comphase_nn(odd),SNR);%同相过后的ri
R_comphase(even)=awgn(R_comphase_nn(even),SNR);%
%Noise{i}= [R_comphase(odd)-R_comphase_nn(odd);R_comphase(even)-R_comphase(even)];%
Noise(odd)=R_comphase(odd)-R_comphase_nn(odd);
Noise(even)=R_comphase(even)-R_comphase_nn(even);
P_noise(odd)=norm(Noise(odd))^2;%噪声功率Nk
P_noise(even)=norm(Noise(even))^2;
R_comphase(even)=conj(R_comphase(even));
%alpha(i)=norm([R_comphase(odd),R_comphase(even)])/P_noise(i);%alpha
alpha(odd)=norm(R_comphase(odd))/P_noise(odd);%%正比于rk/Nk
alpha(even)=norm(R_comphase(even))/P_noise(even);%
% alpha(i)=norm(R_comphase_nn(odd));%奇 偶等大
R_comphase(odd)=R_comphase(odd)*alpha(odd);
R_comphase(even)=R_comphase(even)*alpha(even);
H_comphase(odd,:)=[h_comphase(1),h_comphase(2)]*alpha(odd);
H_comphase(even,:)=[h_comphase(2),-h_comphase(1)]*alpha(even);
end
%_____________________________________________________%
%scatterplot(reshape(cell2mat(r),1,n_phase))
%scatterplot(reshape(cell2mat(R),1,n_phase))
%scatterplot(reshape(cell2mat(R_comphase),1,n_phase))
end
%______________________信源部分________________________%
c_source=rand(n,1);
c_source(c_source==1)=[];%剔除1,强制[0,0.5)和[0.5,1)等概率
c_source(c_source<0.5)=-1;%等概率前提近似取等号,免去信源编码;双极性。
c_source(c_source>=0.5)=1;
n_deng=length(c_source);%重新数出个数
if mod(n_deng,2) ~= 0
c_source(1)=[];
n_deng=n_deng-1;%强制c_source为偶数个
end
c_element=c_source;
c_length=n_deng;%结构体c储存
%
%不进行信道编码,防止对误码性能产生影响
%
%_____________________________________________________%
%____________________QPSK调制_________________________%
%B_map=[1+1i 1-1i -1-1i -1+1i];%%%%B方式调制
n_phase=c_length/2;
c_IQ=reshape(c_element,n_phase,2);%串并转换
c_phase=((c_IQ(:,1)*1i)+(c_IQ(:,2)));%相位映射
%scatterplot(c_phase)
B_jugle=[[1+1i;1+1i],[1+1i;1-1i],[1+1i;-1-1i],[1+1i;-1+1i], ...
[1-1i;1+1i],[1-1i;1-1i],[1-1i;-1-1i],[1-1i;-1+1i], ...
[-1-1i;1+1i],[-1-1i;1-1i],[-1-1i;-1-1i],[-1-1i;-1+1i], ...
[-1+1i;1+1i],[-1+1i;1-1i],[-1+1i;-1-1i],[-1+1i;-1+1i]];
%_____________________________________________________%
%____________________天线发射_________________________%
n_antenna=2;%发射天线数目为二
n_each_antenna=n_phase/n_antenna;
antenna=reshape(c_phase,n_each_antenna,n_antenna);
c_STBC = cell(n_each_antenna,1);%预设大小
%X=cell(n_each_antenna,1);
for i=1:n_each_antenna
c_STBC{i}=[antenna(i,:);[-1*conj(antenna(i,2)),conj(antenna(i,1))]];
%X{i}=antenna(i,:)';
end
%_____________________________________________________%
%______________________分集合并_MRC合并_____________________%
R_comphase_s=zeros(2*n_each_antenna
没有合适的资源?快使用搜索试试~ 我知道了~
Alamouti空时码_空时码_alamouti多天线_mimo_源码
共1个文件
txt:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 2 浏览量
2021-10-04
01:20:01
上传
评论 1
收藏 2KB ZIP 举报
温馨提示
Alamouti空时码在matlab仿真平台上进行各种情况多天线的比较
资源详情
资源评论
资源推荐
收起资源包目录
Alamouti空时码.zip (1个子文件)
Alamouti空时码.txt 18KB
共 1 条
- 1
食肉库玛
- 粉丝: 66
- 资源: 4738
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0