%%
%% 在8PSK调制下,Alamouti方案多发多收在瑞利衰落信道下的性能
%%
clear all
datasize=100000; % 仿真的符号数
EbNo=0:2:20; % 信噪比
M=32; % QPSK modulation
x=randsrc(2,datasize/2,[0:7]); % 数据源符号//行列不变
x1=pskmod(x,M,pi/4);
h=randn(8,datasize/2)+j*randn(8,datasize/2); %Rayleigh衰落信道
h=h./sqrt(2);
for indx=1:length(EbNo)
sigma1=sqrt(1/(4*10.^(EbNo(indx)/10))); % SISO信道高斯白噪声标准差
n=sigma1*(randn(2,datasize/2)+j*randn(2,datasize/2));
y=x1+n; % 通过AWGN信道
y1=x1+n./h(1:2,:); % 通过SISO瑞利衰落信道后的判决变量
x2=pskdemod(y,M,pi/4);
x3=pskdemod(y1,M,pi/4);
sigma2=sqrt(1/(2*10.^(EbNo(indx)/10))); % Alamouti方案每个子信道高斯白噪声标准差
n=sigma2*(randn(8,datasize/2)+j*randn(8,datasize/2));
n1(1,:)=(conj(h(1,:)).*n(1,:)+h(2,:).*conj(n(2,:)))./(sum(abs(h(1:2,:)).^2)); % 2发1收Alamouti方案判决变量中的噪声项
n1(2,:)=(conj(h(2,:)).*n(1,:)-h(1,:).*conj(n(2,:)))./(sum(abs(h(1:2,:)).^2));
y=x1+n1;
x4=pskdemod(y,M,pi/4);
n2(1,:)=(conj(h(1,:)).*n(1,:)+h(2,:).*conj(n(2,:))+conj(h(3,:)).*n(3,:)+h(4,:).*conj(n(4,:)))./(sum(abs(h(1:4,:)).^2)); % 2发2收Alamouti方案判决变量中的噪声项
n2(2,:)=(conj(h(2,:)).*n(1,:)-h(1,:).*conj(n(2,:))+conj(h(4,:)).*n(3,:)-h(3,:).*conj(n(4,:)))./(sum(abs(h(1:4,:)).^2)); %第二时隙,
y1=x1+n2;
x5=pskdemod(y1,M,pi/4);
n3(1,:)=(conj(h(1,:)).*n(1,:)+h(2,:).*conj(n(2,:))+conj(h(3,:)).*n(3,:)+h(4,:).*conj(n(4,:))+ conj(h(5,:)).*n(5,:)+h(6,:).*conj(n(6,:)))./(sum(abs(h(1:6,:)).^2)); % 2发2收Alamouti方案判决变量中的噪声项
n3(2,:)=(conj(h(2,:)).*n(1,:)-h(1,:).*conj(n(2,:))+conj(h(4,:)).*n(3,:)-h(3,:).*conj(n(4,:))+ conj(h(6,:)).*n(5,:)-h(5,:).*conj(n(6,:)))./(sum(abs(h(1:6,:)).^2)); %第二时隙,
y1=x1+n3;
x6=pskdemod(y1,M,pi/4);
n4(1,:)=(conj(h(1,:)).*n(1,:)+h(2,:).*conj(n(2,:))+conj(h(3,:)).*n(3,:)+h(4,:).*conj(n(4,:))+ conj(h(5,:)).*n(5,:)+h(6,:).*conj(n(6,:))+conj(h(7,:)).*n(7,:)+h(8,:).*conj(n(8,:)))./(sum(abs(h).^2)); % 2发2收Alamouti方案判决变量中的噪声项
n4(2,:)=(conj(h(2,:)).*n(1,:)-h(1,:).*conj(n(2,:))+conj(h(4,:)).*n(3,:)-h(3,:).*conj(n(4,:))+ conj(h(6,:)).*n(5,:)-h(5,:).*conj(n(6,:))+conj(h(8,:)).*n(7,:)-h(7,:).*conj(n(8,:)))./(sum(abs(h).^2)); %第二时隙,
y1=x1+n4;
x7=pskdemod(y1,M,pi/4);
[temp,ber1(indx)]=biterr(x,x2,log2(M));
[temp,ber2(indx)]=biterr(x,x3,log2(M));
[temp,ber3(indx)]=biterr(x,x4,log2(M));
[temp,ber4(indx)]=biterr(x,x5,log2(M));
[temp,ber5(indx)]=biterr(x,x6,log2(M));
[temp,ber6(indx)]=biterr(x,x7,log2(M));
end
figure;
semilogy(EbNo,ber2,'-o',EbNo,ber3,'-<',EbNo,ber4,'->',EbNo,ber5,'-d',EbNo,ber6,'-^')
grid on
legend('未采用编码','2发1收Alamouti方案','2发2收Alamouti方案','2发3收Alamouti方案','2发4收Alamouti方案');
xlabel('信噪比EbNo(dB)');
ylabel('误比特率(BER)');
title('三十二进制调制下的性能曲线(32PSK)');