📄 psk调制解调程序.txt
字号:
clear all
close all
i=10;
j=5000;
fc=4;
fm=i/5;
B=2*fm;
t=linspace(0,5,j);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%产生基带信号
a=round(rand(1,i));
st1=t;
for n=1:10
if a(n)<1;
for m=j/i*(n-1)+1:j/i*n
st1(m)=0;
end
else
for m=j/i*(n-1)+1:j/i*n
st1(m)=1;
end
end
end
subplot(321);
plot(t,st1);
title('基带信号');
axis([0,5,-1,2]);
st2=t; %基带信号求反
for k=1:j;
if st1(k)>=1;
st2(k)=0;
else
st2(k)=1;
end
end;
subplot(322);
plot(t,st2);
title('基带信号反码');
axis([0,5,-1,2]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%载波信号
s1=sin(2*pi*fc*t);
s2=sin(2*pi*fc*t+pi);
subplot(323);
plot(s1);
title('载波信号');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%调制
p1=st1.*s1;
p2=st2.*s2;
subplot(324);
plot(t,p1);
title('st1*s1');
subplot(325);
plot(t,p2);
title('st2*s2');
e_psk=p1+p2;
subplot(326);
plot(t,e_psk);
title('e_2psk');
noise=rand(1,j);
psk=e_psk+noise;%加入噪声
figure(2);
subplot(411);
plot(t,psk);
title('加噪后波形');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%相干解调
psk=psk.*s1;%与载波相乘
subplot(412);
plot(t,psk);
title('与载波相乘后波');
[f,af] = T2F(t,psk);%通过低通滤波器
[t,psk] = lpf(f,af,B);
subplot(413);
plot(t,psk);
title('通过低通滤波器波形');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%抽样判决
for m=0:i-1;
if psk(1,m*500+250)<0;
for j=m*500+1:(m+1)*500;
psk(1,j)=0;
end
else
for j=m*500+1:(m+1)*500;
psk(1,j)=1;
end
end
end
subplot(414);
plot(t,psk);
axis([0,5,-1,2]);
title('抽样判决后波形')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -