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

📄 smedge2_16qam.m

📁 我们现在GSM/EDGE信号采用的是旋转的8PSK调制方式
💻 M
字号:
%function p=smedge2(snr_in_dB);
E = 1;
snr_in_dB=35;%%%%%%%%%%%%%%%%%      we can change snr_in_dB' value here
SNR = exp(snr_in_dB*log(10)/10);   %singal to noise ratio
sgma = E/sqrt(2*SNR);              %sigma,standard deviation of noise
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%           smedge finds the probability of error for the given
%           snr_in_dB,signal to noise ration in dB.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a2=[0 pi/4 pi/2 3*pi/4 pi -pi/4 -pi/2 -3*pi/4];
a4=[0 0 0;0 0 1;0 1 1;0 1 0;1 1 0;1 0 0;1 0 1;1 1 1];

b2=exp(j*a2);
M=8;
N=2000;%符号              
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ck = 2;
input=round(rand(1,log2(M)*N)); 

theta(1)=0; %初始相位
R1=2;
for i=1:4:length(input)-4
    if ((input(i)==1)&(input(i+1)==1)&(input(i+2)==1))
        del_theta=-3*pi/4;
    elseif ((input(i)==0)&(input(i+1)==1)&(input(i+2)==1))
        del_theta=pi/2;
          elseif ((input(i)==0)&(input(i+1)==1)&(input(i+2)==0))
        del_theta=3*pi/4;
          elseif ((input(i)==0)&(input(i+1)==0)&(input(i+2)==0))
        del_theta=0;
          elseif ((input(i)==1)&(input(i+1)==1)&(input(i+2)==0))
        del_theta=pi;
          elseif ((input(i)==1)&(input(i+1)==0)&(input(i+2)==0))
        del_theta=-pi/4;
          elseif ((input(i)==1)&(input(i+1)==0)&(input(i+2)==1))
        del_theta=-pi/2;
          elseif ((input(i)==0)&(input(i+1)==0)&(input(i+2)==1))
         del_theta=pi/4;
     end 
     theta(R1)=del_theta+R1*3*pi/8;
     
     if (input(i+3) == 0)
           x1(R1)=exp(j*theta(R1));
       elseif(input(i+3) == 1)
           x1(R1)=ck*exp(j*theta(R1));
     end
     
     R1=R1+1;
 end
 et=x1;
 
 figure(1);
 plot(et(4:1500));
 title('e(t):rotate 3/8pi');
 
 %insert zeros
for i=1:length(et)
 etx(2*i-1)=real(et(i));
 ety(2*i-1)=imag(et(i));
end

for i=1:length(et);
  etx(2*i)=0;
  ety(2*i)=0;
end

et_insert_zeros=etx+j*ety;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%et_insert_zeros_add_noise=etx_noise+j*ety_noise;%add noise
%et_insert_zeros_add_noise=et_insert_zeros+gngauss2(sgma);
%%%%%%%%%

%%%gsm/edge pulse shaping
tx=[-0 0.0007 0.0315 0.2604 0.7057 0.9268 0.7057 0.2605 0.0315 0.0008 0];
shaped_et=filter(tx,1,[et_insert_zeros]);
figure(2);
plot(shaped_et,'.');
%title('pulse shape');
%%%%%%add nosie:
for i=1:length(shaped_et)
shaped_et_add_noise(i)=shaped_et(i)+gngauss2(sgma);
end
%%%%%%%%
c_opt=[0         0   -0.0031    0.1384   -1.1360    2.7314   -1.1360    0.1384   -0.0031         0         0];%coefficient of RX
equalized_st=filter(c_opt,1,[shaped_et_add_noise]);%zero forcing filter   
equalized_st=equalized_st(3:length(equalized_st));%adjust the delay
figure(4);
plot(equalized_st,'.');
title('equalized-st');
%%%%%
for i=1:2:length(equalized_st)
   downsampled_equalizer_output((i+1)/2)=equalized_st(i);%underdown sampling
end
downsampled_equalizer_output=downsampled_equalizer_output(5:length(downsampled_equalizer_output));
figure(5);
plot(downsampled_equalizer_output,'.');
title('after receiver with no ISI');

%%%%%%%%%%%jugde :first, abs,rotate back
abs_sby = abs(downsampled_equalizer_output);
  x=real(downsampled_equalizer_output);
  y=imag(downsampled_equalizer_output);
  x=real(downsampled_equalizer_output);
  y=imag(downsampled_equalizer_output);
for i=2:length(downsampled_equalizer_output)-1;
    theta2(i)=qxw(x(i),y(i));
    theta3(i)=theta2(i)-i*3*pi/8;
end
x2=exp(j*theta3);
figure(6);
plot(x2,'*');
title('normal 8psk');
epsk_out=[];

x_judge=real(x2);
y_judge=imag(x2);
for i=2:length(x2)-1
      phase1(i)=qxw(x_judge(i),y_judge(i));
      %%%%%%
     if( (phase1(i)-(-3.1414))<=0.4 )
          phase1(i)=3.1414;
     end
      
      %%%%%%
      s=abs(phase1(i)-a2(1)); 
    m=1;
       for k=2:8
        if s>abs((phase1(i)-a2(k)))
          m=k;
          s=abs((phase1(i)-a2(k)));
      end
     end
   epsk_out=[epsk_out a4(m,:)];  
   %%%%%%%%%%%%
    if(abs(abs_sby(i)-ck) <= 0.8  && i <=length(abs_sby))
           epsk_out=[epsk_out 1];
     else
           epsk_out=[epsk_out 0];
     end
   %%%%%%%%%%%
end

%%probility:
ps=0;
for n=1:min(length(input),length(epsk_out))
    if( input(n)==epsk_out(n))
        continue;
        else
            n
      ps=ps+1;
  end
end
p=ps/(4*N)

⌨️ 快捷键说明

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