📄 bpsk.m
字号:
clear;
fs=100;
fc=3;
ts=1/fs;
fd=1;
code=randint(1,10);
[x,m]=pluse(code,fs,fd);
x=1-2.*x;
t=ts:ts:length(code);
c=sin(2*pi*fc*t);
y=x.*c;
X=fft(x);
Y=fft(y);
C=fft(c);
n=length(x);
f=[0:fs/n:fs-fs/n]-fs/2;
y=awgn(y,10);
r=y;
wn=[0.04,0.08];
[B,A]=butter(5,wn);
r=filtfilt(B,A,r);
cc=sin(2*pi*fc*t);
rr=r.*cc;
[B,A]=butter(5,0.07);
rrr=2.*filtfilt(B,A,rr);
R=fft(r);
RR=fft(rr);
RRR=fft(rrr);
n=length(r);
for k=50:100:n;
if rrr(k)>0
rrrr((k/50+1)/2)=0;
elseif rrr(k)<0
rrrr((k/50+1)/2)=1;
end
end
BER=sum(abs(rrrr-code));
BER=BER/length(code);
figure(1);
subplot(3,2,1);
plot(t,x(1:length(t)));
title('随机序列脉冲');
subplot(3,2,2);
plot(f,abs(fftshift(X)));
title('随机序列脉冲频谱');
subplot(3,2,3);
plot(t,c(1:length(t)));
title('载波信号');
subplot(3,2,4);
plot(f,abs(fftshift(C)));
title('载波频谱');
subplot(3,2,5);
plot(t,y(1:length(t)));
title('已调信号');
subplot(3,2,6);
plot(f,abs(fftshift(Y)));
title('已调信号频谱');
figure(2);
subplot(3,2,1);
plot(t,r(1:length(t)));
title('');
subplot(3,2,2);
plot(f,abs(fftshift(R)));
title('');
subplot(3,2,3);
plot(t,rr(1:length(t)));
title('');
subplot(3,2,4);
plot(f,abs(fftshift(RR)));
title('');
subplot(3,2,5);
plot(t,rrr(1:length(t)));
title('');
subplot(3,2,6);
plot(f,abs(fftshift(RRR)));
title('');
[q,m]=pluse(-rrrr,fs,fd);
figure(3);
subplot(2,1,1);
plot(t,x(1:length(t)));
subplot(2,1,2);
plot(t,q(1:length(t)));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -