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

📄 cycle_shift_delay15a.m

📁 是自己自创的好程序
💻 M
字号:
clear all;
close all;
tic;
Nt=4;
fs=2e6;
Nfft=256;
fdelta=fs/Nfft;
Pow=[0 -4 -8];  %heavy multipath
Delay=[0 1.5 4]*1e-6;
hh=10.^(Pow/20);
norm_h=hh./norm(hh);
H=zeros(1,128);
%  %h2=zeros(1,128);
%  for ant=1:Nt
%     h=norm_h.*exp(sqrt(-1)*2*pi*rand(1,length(Pow)));
%     for k=1:128,
%         f=(k-1)*fdelta;
%         H(1,k)=h*exp(sqrt(-1)*2*pi*Delay'*f);
%     end;
%     channel_h_new(ant,:)=H(1,1:128);
%  end
% hha=channel_h_new(1,1:4:128);
% hhb=channel_h_new(2,1:4:128);
% hhc=channel_h_new(3,1:4:128);
% hhd=channel_h_new(4,1:4:128);
jay=exp(sqrt(-1)*pi/4);
snr=20;
Line_snr=power(10,snr/20);
for trial=1:100
for ant=1:Nt
    h=norm_h.*exp(sqrt(-1)*2*pi*rand(1,length(Pow)));
    %Delay(2)=(randint(1,1,[1,30])/30)*1e-6;
    %Delay=[0,randint(1,2,[1,20])*1e-6;
    %Delay=randint(,3,[0,8]);
    for k=1:128,
        f=(k-1)*fdelta;
        H(1,k)=h*exp(sqrt(-1)*2*pi*Delay'*f);
    end;
    channel_h_new(ant,:)=H(1,1:128);
 end
hha=channel_h_new(1,1:4:128);
hhb=channel_h_new(2,1:4:128);
hhc=channel_h_new(3,1:4:128);
hhd=channel_h_new(4,1:4:128);
%h1=kron(ones(1,4),hha);
ha=kron(ones(1,4),hha);
h1=ha;
hb=kron(hhb,ones(1,4));
hc=kron(hhc,ones(1,4));
hd=kron(hhd,ones(1,4));
h2=hb.*exp(sqrt(-1)*(1:128)*32/128);
h3=hc.*exp(sqrt(-1)*(1:128)*64/128);
h4=hd.*exp(sqrt(-1)*(1:128)*96/128);
%x=(1-2*randint(1,128)+sqrt(-1)*(1-2*randint(1,128)))/sqrt(2);
X_signal=randint(1,128,4);
mod_signal=(qammod(X_signal,4))/sqrt(2);
%data_signal=qamdemod(mod_signal,4);
%X-data_signal
sum_h=diag(h1)+diag(h2)+diag(h3)+diag(h4);
Y=sum_h*mod_signal.';
Y=awgn(Y,snr);
decode_Y=inv(sum_h'*sum_h+(eye(128)/Line_snr))*sum_h'*Y;
data_out=qamdemod(decode_Y,4);
[ratio,number]=biterr(data_out.',X_signal);
%decode_Y-X.'
abs_X=complex(abs(real(decode_Y)),abs(imag(decode_Y)));
power=mean(abs(abs_X).^2);
Noise=var(abs_X);
SNR_x=10*log10(power/Noise);
SNR_trial(trial)=SNR_x; 
BER_trial(trial)=ratio;
%add the Four ration degree of the content.
%add the no cycle shift delay the content.
hb=kron(hhb,ones(1,4));
hc=kron(hhc,ones(1,4));
hd=kron(hhd,ones(1,4));
h2=hb;%.*exp(sqrt(-1)*(1:128)*32/128);
h3=hc;%.*exp(sqrt(-1)*(1:128)*64/128);
h4=hd;%*exp(sqrt(-1)*(1:128)*96/128);
%x=(1-2*randint(1,128)+sqrt(-1)*(1-2*randint(1,128)))/sqrt(2);
X_signal=randint(1,128,4);
mod_signal=(qammod(X_signal,4))/sqrt(2);
%data_signal=qamdemod(mod_signal,4);
%X-data_signal
sum_h=diag(h1)+diag(h2)+diag(h3)+diag(h4);
Y=sum_h*mod_signal.';
Y=awgn(Y,snr);
x_decode_Y=inv(sum_h'*sum_h+(eye(128)/Line_snr))*sum_h'*Y;
x_data_out=qamdemod(x_decode_Y,4);
[ratio1,number1]=biterr(x_data_out.',X_signal);
%decode_Y-X.'
abs_X=complex(abs(real(x_decode_Y)),abs(imag(x_decode_Y)));
power=mean(abs(abs_X).^2);
Noise=var(abs_X);
SNR_x=10*log10(power/Noise);
x_SNR_trial(trial)=SNR_x; 
x_BER_trial(trial)=ratio;

%X1=mod_signal(1:32);X2=mod_signal(33:64);X3=mod_signal(65:96);X4=mod_signal(97:128);
X=reshape(mod_signal,4,[]);
%X=Mapper(XX,2);
for i=1:length(X)
%h=(randn(1,4)+sqrt(-1)*randn(1,4))/sqrt(2);
h1=hha(1,i);h2=hhb(1,i);h3=hhc(1,i);h4=hhd(1,i);
H=[h1,h2,h3,h4].';
s1=X(1,i); s2=X(2,i); s3=jay*X(3,i); s4=jay*X(4,i);
A=[s1,s2; -s2',s1']; B=[s3,s4;-s4',s3'];
S1=[A,B;B,A];
%S1(:,[3,4])=S1(:,[3,4]);
H=[h1,h2,h3,h4].';
Rot_signal=S1*H;
Rot_signal=awgn(Rot_signal,snr);
RR_signal=[Rot_signal(1,1),conj(Rot_signal(2,1)),Rot_signal(3,1),conj(Rot_signal(4,1))].';
rot_H=[h1,h2,jay*h3,jay*h4;
      h2',-h1',jay*h4',-jay*h3';
      h3,h4,jay*h1,jay*h2;
      h4',-h3',jay*h2',jay*-h1'];
R_det_signal=inv(rot_H'*rot_H+(eye(4)/Line_snr))*rot_H'*RR_signal;
Rotation_trial((i-1)*4+1:i*4)=R_det_signal;
end;
Rotation_data=qamdemod(Rotation_trial,4);
%Rotation_data=deMapper(Rotation_trial,2);
[ratio2,number2]=biterr(Rotation_data,X_signal);
%add the Four ration degree of the content.
abs_X=complex(abs(real(Rotation_trial)),abs(imag(Rotation_trial)));
power=mean(abs(abs_X).^2);
Noise=var(abs_X);
SNR_x=10*log10(power/Noise);
xx_SNR_trial(trial)=SNR_x; 
end;
toc;



⌨️ 快捷键说明

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