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

📄 fsk2.m

📁 自己写的2fsk调制解调程序
💻 M
字号:
clear;
fs=100;
fc1=10;
fc2=6;
ts=1/fs;
fd=1;
code=randint(1,10);
[x,m]=pluse(code,fs,fd);
t=ts:ts:length(code);
c1=sin(2*pi*fc1*t);
c2=sin(2*pi*fc2*t);
y=x.*c1+(1-x).*c2;
X=fft(x);
Y=fft(y);
C1=fft(c1);
C2=fft(c2);
n=length(x);
f=[0:fs/n:fs-fs/n]-fs/2;
y=awgn(y,10);
r=y;
wn1=[0.18,0.22];
wn2=[0.1,0.14];
[B,A]=butter(5,wn1);
[C,D]=butter(5,wn2);
r1=filtfilt(B,A,r);
r2=filtfilt(C,D,r);
rr1=r1.*c1;
rr2=r2.*c2;
[B,A]=butter(5,0.2);
[C,D]=butter(5,0.13);
rrr1=2.*filtfilt(B,A,rr1);
rrr2=2.*filtfilt(C,D,rr2);
R=fft(r);
R1=fft(r1);
R2=fft(r2);
RR1=fft(rr1);
RR2=fft(rr2);
RRR1=fft(rrr1);
RRR2=fft(rrr2);
SAM=rrr1-rrr2;
SAM1=sign(SAM);
SAM1=(SAM1+1)/2;
[num,BER]=biterr(x,SAM1);
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,c1(1:length(t)));
title('');
subplot(3,2,4);
plot(f,abs(fftshift(C1)));
title('');
subplot(3,2,5);
plot(t,c2(1:length(t)));
title('');
subplot(3,2,6);
plot(f,abs(fftshift(C2)));
title('');
figure(2);
subplot(3,2,1);
plot(t,y(1:length(t)));
title('');
subplot(3,2,2);
plot(f,abs(fftshift(Y)));
title('');
subplot(3,2,3);
plot(t,rr1(1:length(t)));
title('');
subplot(3,2,4);
plot(f,abs(fftshift(RR1)));
title('');
subplot(3,2,5);
plot(t,rr2(1:length(t)));
title('');
subplot(3,2,6);
plot(f,abs(fftshift(RR2)));
title('');
figure(3);
subplot(3,2,1);
plot(t,rrr1(1:length(t)));
title('');
subplot(3,2,2);
plot(f,abs(fftshift(RRR1)));
title('');
subplot(3,2,3);
plot(t,rrr2(1:length(t)));
title('');
subplot(3,2,4);
plot(f,abs(fftshift(RRR2)));
title('');
subplot(3,2,5);
plot(t,x(1:length(t)));
subplot(3,2,6);
plot(t,SAM1(1:length(t)));

⌨️ 快捷键说明

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