energytest.m

来自「Modem设计中的能量检测模块」· M 代码 · 共 51 行

M
51
字号
clear;
runtime=1;
%snr=[0.5,0.75,1.0,1.25,1.5];
%runtime=[100,100,100,200,1000];
q=4;
BITN=1024;
N=q*BITN;

EbNo=2; %dB
rate=1/q;
amp=1/sqrt(10.^(EbNo/10)*2*rate*2);  %The Last *2 is due to QPSK
Varn=amp^2;
Lc=2/amp^2;

	%%%%Encoder
	info=sign(rand(1,BITN)-0.5); %0<--->+1,1<--->-1;
    IntRA=randperm(N);
    acc=RA_Encoder(info,q,IntRA);  
    
    %%%%QPSK Mapping
	HN=fix(N/2);thn=0:HN-1;
	Ibit=acc(2*thn+1);Qbit=acc(2*thn+2);
	circle=exp(-i*pi/4);
	qpsk=1/sqrt(2)*(Ibit+i*Qbit)*circle; %Mapping : 11-->pi/4-pi/4; -1,-1-->pi+pi/4-pi/4; 1,-1-->-pi/4-pi/4; -1,1-->3*pi/4-pi/4
    
	%%%%Add pilot symbol And Block Based DPSK Coding
    %%Block number=Hop, BT symbols/each block.
	T=32;  % BT=T+1 represents coherence time- Invariant.
	BT=T+1; Hop=fix(HN/T);WHN=HN+Hop;  % Hop represnts the number of blocks, WHN denotes the received symbol length.
	iv=0:Hop-1;
	tn=0:N-1;
	tiv=(T+1)*iv;
	transqpsk(BT*iv+1)=ones(1,Hop);
	transqpsk(fix(thn/T)+thn+2)=qpsk;
    %%%%AWGN Channels
	y=transqpsk+amp*(randn(1,WHN)+i*randn(1,WHN));
    zy=amp*(randn(1,WHN)+i*randn(1,WHN));
    
    
    for deltT=1:1:100
        energyAccSigNois(deltT) = sum(abs(y(1:deltT)))/deltT;
        energyAccNois(deltT) = sum(abs(zy(1:deltT)))/deltT;
        deltEnergy(deltT) = energyAccSigNois(deltT) - energyAccNois(deltT);
    end
    tt=1:100;
    plot(tt,energyAccNois,'r');
    hold
    plot(tt,energyAccSigNois,'g');
    plot(tt,deltEnergy);
   
 

⌨️ 快捷键说明

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