⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tx3rx1_stbc.m

📁 三发一收的STBC误码率仿真
💻 M
字号:
clear all;

Eb_N0=[0:4:30 100];				%Eb_N0
wei1=[0 1 3 5 10 20 50 100];
wei2=[0 1 3 5 10 20 50 100];

error_stbc3=zeros(length(wei1),length(wei2),length(Eb_N0));
for jj=1:length(wei1)
    for mm=1:length(wei2)
error=zeros(size(Eb_N0));								%误码存储
numbits=1e6;								%仿真点数
weight1=wei1(jj);
weight2=wei2(mm);
ch=sqrt([1,db2lin(weight1),db2lin(weight1+weight2)]/(1+db2lin(weight1)+db2lin(weight1+weight2)));
z1=zeros(1,2);
warning off
for m=1:length(Eb_N0)
    disp([jj m])
    snr=Eb_N0(m)+lin2db(6);							%计算snr
    for ii=1:(numbits/6)
        source1=randint(1,6);
        source=source1;
        source(source==0)=-1;					%产生随机比特
        x(1,1)=source(1)+j*source(2);
        x(1,2)=source(3)+j*source(4);			%QPSK调制,格雷码
        x(1,3)=(source(5)+j*source(6))/sqrt(2);
        x(2,1)=-conj(x(1,2));
        x(2,2)=conj(x(1,1));
        x(2,3)=x(1,3);                         %确定第二根天线发射信号
        x(3,1)=conj(x(1,3));
        x(3,2)=conj(x(1,3));
        x(3,3)=imag(x(1,2))-real(x(1,1));      %确定第三根天线发射信号
        x(4,1)=conj(x(1,3));
        x(4,2)=-conj(x(1,3));
        x(4,3)=imag(x(1,1))+real(x(1,2));      %确定第三根天线发射信号
        
        x=x/sqrt(2);							%符号能量归一化
        
        h1=(randn(1,3)+j*randn(1,3)).*ch;
        h1=repmat(h1,4,1)						%产生信道特性
        
        y1=x.*h1;								%乘以信道特性
        r1=sum(y1,2);							%两径信号相加
        %r1=awgn(r1,snr,3);						%Guass噪声
	    r1=r1+(randn(size(r1))+j*randn(size(r1)))/sqrt(2*db2lin(snr));
        
        z1(1)=conj(h1(1,1))*r1(1)+conj(r1(2))*h1(1,2)+(r1(4)-r1(3))*conj(h1(1,3))/2-conj(r1(4)+r1(3))*h1(1,3)/2;
        z1(2)=conj(h1(1,2))*r1(1)-h1(1,1)*conj(r1(2))+(r1(4)+r1(3))*conj(h1(1,3))/2+conj(r1(4)-r1(3))*h1(1,3)/2;	
        z1(3)=(r1(1)+r1(2))*conj(h1(1,3))+conj(r1(3))*(h1(1,1)+h1(1,2))+conj(r1(4))*(h1(1,1)-h1(1,2));	%算出发射信号
        rec1(1)=real(z1(1))>0;   
        rec1(2)=imag(z1(1))>0;
        rec1(3)=real(z1(2))>0;
        rec1(4)=imag(z1(2))>0;
        rec1(5)=real(z1(3))>0;
        rec1(6)=imag(z1(3))>0;                          %判决
        error(1,m)=error(1,m)+sum(rec1~=source1);		%误码累加
        
%         y2=x;											%以下是对guass信道
%         r2=sum(y2,1);									%思路同上
%         r2=awgn(r2,snr,3);
% 	     z2(1)=r2(1)+conj(r2(2));
%         z2(2)=-conj(r2(1))+r2(2);
%         rec2(1)=real(z2(1))>0;   
%         rec2(2)=imag(z2(1))>0;
%         rec2(3)=real(z2(2))>0;
%         rec2(4)=imag(z2(2))>0;
%         rec2(rec2==0)=-1;
%         error(2,m)=error(2,m)+sum(rec2~=source);
    end
end
error(error==0)=1;	
error=error/numbits;
error_stbc3(jj,mm,:)=error;
%semilogy(Eb_N0,error(1,:),'m*-');
warning on
%eval(['save ber_stbc2_weight' num2str(weight) ' error']);
end
end

eval(['save ber_stbc3_weight wei1 wei2 Eb2N0 error_stbc3']);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -