📄 cycle_shift_delay18a.m
字号:
clear all;
close all;
Nfft=128;
tic;
snr=20;
tau1=[0];
pwd1=[0];
tau2=[0];
pwd2=[0];
% tau=[0];
% pwd=[0];
for trial=1:1000
transmit=randint(2,128,4);
transmit_signal=qammod(transmit,4)/sqrt(2);
h1=zeros(1,128);
h2=zeros(1,128);
h1(tau1+1)=10.^(pwd1/20).*exp(sqrt(-1)*2*pi*randn(1,length(tau1)));
norm_h1=h1/norm(h1);
h2(tau2+1)=10.^(pwd2/20).*exp(sqrt(-1)*2*pi*randn(1,length(tau2)));
norm_h2=h2/norm(h2);
F=ifft(eye(Nfft))*sqrt(Nfft);
%F=ifftshift(F,2);
fh1=F'*norm_h1.';
fh2=F'*norm_h2.';
%fh1=ones(128,1);
%fh2=ones(128,1);
%add the STBC of the content.
x1=transmit_signal(1,:); x2=transmit_signal(2,:);
R1=diag(x1)*fh1+diag(x2)*fh2;
R2=diag(-conj(x2))*fh1+diag(conj(x1))*fh2;
R1=awgn(R1,snr);
R2=awgn(R2,snr);
%add the detection of the STBC.
beta_x1=diag(conj(fh1))*R1+diag(fh2)*conj(R2);
beta_x2=diag(conj(fh2))*R1-diag(fh1)*conj(R2);
decode_data(1,:)=beta_x1;
decode_data(2,:)=beta_x2;
decode_demod=qamdemod(decode_data,4);
[num,ratio]=symerr(transmit,decode_demod);
%add the STBC of the content.
%add the cycle shift delay.
shift_t1=norm_h1;
%shift_t2=h;
shift_t2=[norm_h2((128-6):128),norm_h2(1:128-6-1)];
%shift_hf1=F'*shift_t1;
shift_h1=F'*shift_t1.';
shift_h2=F'*shift_t2.';
% shift_h1=ones(128,1);
% shift_h2=ones(128,1);
%add the cycle shift delay.
sum_shift=shift_h1+shift_h2;
shift_R1=diag(x1)*shift_h1+diag(x1)*shift_h2;
shift_R2=diag(x2)*shift_h1+diag(x2)*shift_h2;
shift_R1=awgn(shift_R1,snr);
shift_R2=awgn(shift_R2,snr);
decode_shift1=diag(conj(sum_shift))*shift_R1;
decode_shift2=diag(conj(sum_shift))*shift_R2;
decode_shift(1,:)=decode_shift1;
decode_shift(2,:)=decode_shift2;
shift_decode=qamdemod(decode_shift,4);
[num1,ratio1]=symerr(transmit,shift_decode);
%add the no cycle shift delay diversity.
shift_t1=norm_h1;
shift_t2=norm_h2;
%shift_t2=[h2((128-6):128),h2(1:128-6-1)];
%shift_hf1=F'*shift_t1;
shift_h1=F'*shift_t1.';
shift_h2=F'*shift_t2.';
% shift_h1=ones(128,1);
% shift_h2=ones(128,1);
%add the cycle shift delay.
sum_shift=shift_h1+shift_h2;
shift_R1=diag(x1)*shift_h1+diag(x1)*shift_h2;
shift_R2=diag(x2)*shift_h1+diag(x2)*shift_h2;
shift_R1=awgn(shift_R1,snr);
shift_R2=awgn(shift_R2,snr);
decode_shift1=diag(conj(sum_shift))*shift_R1;
decode_shift2=diag(conj(sum_shift))*shift_R2;
decode_shift(1,:)=decode_shift1;
decode_shift(2,:)=decode_shift2;
shift_decode=qamdemod(decode_shift,4);
[num2,ratio2]=symerr(transmit,shift_decode);
%add the no cycle shift delay diversity.
STBC(trial)=num;
CSD(trial)=num1;
NO_CSD(trial)=num2;
end;
toc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -