%-------2DPSK调制与解调--------
fs=30000;
Time_Hold_On=0.1;
Num_Unit=fs*Time_Hold_On;
High_Level=ones(1,Num_Unit);
Low_Level=zeros(1,Num_Unit);
f=10;
A=1;
%>>>>>>>>>>>码型变换>>>>>>>>>>>
sign_absolute=randsrc(1,8,[0,1]);%随机产生绝对码
sign_ar=zeros(1,9);
%sign_relative=zeros(1,8);%相对码
%delay_relative=zeros(1,8);%延时一个周期的相对码
for I=1:8
sign_ar(I+1)=xor(sign_ar(I),sign_absolute(I));
end
sign_relative=sign_ar([2:9]);%相对码的产生
delay_relative=sign_ar([1:8]);%延时后的相对码的产生
%>>>>>>>>>>>initial_the_signal>>>>>>>>>>>>>>>>>>>>
Lenth_Of_Sign=length(sign_relative);
st=zeros(1,Num_Unit*Lenth_Of_Sign);%调制后的信号
signal_absolute=zeros(1,Num_Unit*Lenth_Of_Sign);%基带信号(绝对码波形)
signal_relative=zeros(1,Num_Unit*Lenth_Of_Sign);%相对码波形
signal_delay_relative=zeros(1,Num_Unit*Lenth_Of_Sign);%延时相对码波形
signal_result=zeros(1,Num_Unit*Lenth_Of_Sign);%解调后的信号
Na=zeros(1,Num_Unit*Lenth_Of_Sign);%高斯白噪声
Nb=zeros(1,Num_Unit*Lenth_Of_Sign);%高斯白噪声
t=0:1/fs:Lenth_Of_Sign*Time_Hold_On-1/fs;
%>>>>>>>>>>>>>>>>高斯白噪声>>>>>>>>>>>>>>>>>>>>>>>
Na=normrnd(0,0.3,1,Num_Unit*Lenth_Of_Sign);
Nb=normrnd(0,0.2,1,Num_Unit*Lenth_Of_Sign);
%>>>>>>>>>>>>>>>基带信号(绝对码波形)>>>>>>>>>>>>>>>>>>>>
for I=1:Lenth_Of_Sign
if sign_absolute(I)==1
signal_absolute((I-1)*Num_Unit+1:I*Num_Unit)=High_Level;
else
signal_absolute((I-1)*Num_Unit+1:I*Num_Unit)=Low_Level;
end
end
%>>>>>>>>>>>>>>>相对码波形>>>>>>>>>>>>>>>>>>>>
for I=1:Lenth_Of_Sign
if sign_relative(I)==1
signal_relative((I-1)*Num_Unit+1:I*Num_Unit)=High_Level;
else
signal_relative((I-1)*Num_Unit+1:I*Num_Unit)=Low_Level;
end
end
%>>>>>>>>>>>>>>>>信号的调制>>>>>>>>>>>>>>>>>>>>>>
for I=1:Lenth_Of_Sign
if sign_relative(I)==1
st((I-1)*Num_Unit+1:I*Num_Unit)=A*sin(2*pi*f*t((I-1)*Num_Unit+1:...
I*Num_Unit)+pi);
else
st((I-1)*Num_Unit+1:I*Num_Unit)=A*sin(2*pi*f*t((I-1)*Num_Unit+1:...
I*Num_Unit));
end
end
%>>>>>>>>>>>>>>>>延时后调制波形>>>>>>>>>>>>>>>>>>>>>>
for I=1:Lenth_Of_Sign
if delay_relative(I)==1
signal_delay_relative((I-1)*Num_Unit+1:I*Num_Unit)=A*sin(2*pi*f*t...
((I-1)*Num_Unit+1:I*Num_Unit)+pi);
else
signal_delay_relative((I-1)*Num_Unit+1:I*Num_Unit)=A*sin(2*pi*f*t...
((I-1)*Num_Unit+1:I*Num_Unit));
end
end
%>>>>>>>>>>>>>>>信道加噪>>>>>>>>>>>>>>>>
st=Na+st;
signal_delay_relative=Nb+signal_delay_relative;
%>>>>>>>>>>>>>相乘>>>>>>>>>>>>>>>>>>>>
xc=st.*signal_delay_relative;
%>>>>>>>>>>>>低通滤波部分>>>>>>>>>>>>>>
[N,Wn]=buttord(2*pi*10,2*pi*30,3,25,'s');%临界频率采用角频率表示
[b,a]=butter(N,Wn,'s');
[bz,az]=impinvar(b,a,fs);
dt=filter(bz,az,xc);
%>>>>>>>>>>>>>>>>>>>>抽样判决>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
for I=1:Lenth_Of_Sign
if dt((Num_Unit/2)*(2*I-1))<0
signal_result((I-1)*Num_Unit+1:I*Num_Unit)=High_Level;
else
signal_result((I-1)*Num_Unit+1:I*Num_Unit)=Low_Level;
end
end
figure
subplot(7,1,1)
plot(t,signal_absolute,'r');
axis([0,Time_Hold_On*Lenth_Of_Sign,-(A/2),A+(A/2)]);
title(['基带信号','(绝对码波形)'])
grid
subplot(7,1,2)
plot(t,signal_relative,'r');
axis([0,Time_Hold_On*Lenth_Of_Sign,-(A/2),A+(A/2)]);
title(['相对码波形'])
grid
subplot(7,1,3)
plot(t,st,'r');
axis([0,Time_Hold_On*Lenth_Of_Sign,-3*(A/2),A+(A/2)]);
title(['调制后波形'])
grid
subplot(7,1,4)
plot(t,signal_delay_relative,'r');
axis([0,Time_Hold_On*Lenth_Of_Sign,-3*(A/2),A+(A/2)]);
title(['延时后调制信号波形'])
grid
subplot(7,1,5)
plot(t,xc,'r');
axis([0,Time_Hold_On*Lenth_Of_Sign,-3*(A/2),A+(A/2)]);
title(['相乘后的波形'])
grid
subplot(7,1,6)
plot(t,dt,'r');
axis([0,Time_Hold_On*Lenth_Of_Sign,-3*(A/2),A+(A/2)]);
title(['低通滤波后的波形'])
grid
subplot(7,1,7)
plot(t,signal_result,'r');
axis([0,Time_Hold_On*Lenth_Of_Sign,-(A/2),A+(A/2)]);
title(['抽样判决后的波形'])
grid