.
end
figure(2) %画调制图
plot(1:length(transmittedSignal),transmittedSignal);title('Modulation of ASK');grid on;
figure(3)%画频谱实部
m=0:length(transmittedSignal)-1; F=fft(transmittedSignal);
plot(m,abs(real(F))),title('ASK_frequency-domain analysis real'); grid on;
%figure(4) 画频谱虚部
%plot(m,imag(F));title('ASK_frequency-domain analysis imag'); %grid on; end
CheckRatePe代码
function PeWrong=CheckRatePe(signal1,signal2,s) rights=0; wrongs=0; for ki=1:s-2
if(signal1(ki)==signal2(ki)) rights=rights+1; else
wrongs=wrongs+1; end end
PeWrong=wrongs/(wrongs+rights); end
demoASK代码
function bitstream=demoASK(receivedSignal,bitRate,fc,n,N) load num
signal1=receivedSignal;
signal2=abs(signal1); %??á÷
signal3=filter(num1,1,signal2); %LPF,°ü???ì2¨ IN=fix(length(num1)/2); %?ó3ùê±?? bitstream=[]; LL=fc/bitRate*N; i=IN+LL/2;
while (i<=length(signal3)) %?D?? bitstream=[bitstream,signal3(i)>=0.5]; i=i+LL; end
'.
.
figure(6)
subplot(3,1,1); %接收波形
plot(1:length(signal1),signal1);title('Wave of receiving terminal(including noise)');grid on;
subplot(3,1,2);%接收整流后波形
plot(1:length(signal2),signal2);title('Wave of commutate');grid on; subplot(3,1,3);%包络检波波形
plot(1:length(signal3),signal3);title('Wave of LPF');grid on; bit=[];
for i=1:length(bitstream) if bitstream(i)==0 bit1=zeros(1,N); else
bit1=ones(1,N); end
bit=[bit,bit1]; end
figure(7)%解调后的二进制波形
plot(bit),title('binary of receiving terminal'),grid on; axis([0,N*length(bitstream),-2.5,2.5]); end
gussian代码 %加高斯白噪声
function signal=gussian(transmittedSignal,noise) signal=sqrt(2)*transmittedSignal; signal=awgn(signal,noise); figure(5)
plot(1:length(signal),signal);
title('Wave including noise'),grid on; end
fsk主函数代码
close all clear all
n=16;%二进制代码长度 f1=18000000;%频率1 f2=6000000;%频率2 bitRate=1000000;%bit速率 N=50;%码元宽度 %noise=ti;
noise=10;%家性噪声大小
'.
.
signal=source(n,N);%产生二进制代码
transmittedSignal=fskModu(signal,bitRate,f1,f2,N);%调制 signal1=gussian(transmittedSignal,noise);%加噪声 configueSignal=demoFSK(signal1,bitRate,f1,f2,N);%解调
source代码%二进制信号产生函数
function sendSignal=source(n,N) sendSignal=randint(1,n) bit=[];
for i=1:length(sendSignal) if sendSignal(i)==0 bit1=zeros(1,N); else
bit1=ones(1,N); end
bit=[bit,bit1]; end figure(1)
plot(bit),title('transmitting of binary'),grid on; axis([0,N*length(sendSignal),-2.5,2.5]); end
fskModu代码%频率调制函数
function transmittedSignal=fskModu(signal,bitRate,f1,f2,N) t=linspace(0,1/bitRate,N); c1=sin(2*pi*t*f1);%调制信号1 c2=sin(2*pi*t*f2);%调制信号2 transmittedSignal=[]; for i=1:length(signal)%调制 if signal(i)==1
transmittedSignal=[transmittedSignal,c1]; else
transmittedSignal=[transmittedSignal,c2]; end end
figure(2) %画调制后波形图
plot(1:length(transmittedSignal),transmittedSignal);title('Modulation of FSK');grid on; figure(3) %画调制后频谱图
'.
.
m=0:length(transmittedSignal)-1; F=fft(transmittedSignal);
plot(m,abs(real(F))),title('ASK_frequency-domain analysis real'); grid on; end
demoFSK代码
function bitstream=demoFSK(receivedSignal,bitRate,f1,f2,N) load num
signal1=receivedSignal;
signal2=filter(gaotong,1,signal1); %通过HPF,得到高通分量 signal3=abs(signal2); %整流
signal3=filter(lowpass,1,signal3); %通过低通,形成包络 bitstream=[];
IN1=fix(length(lowpass)/2)+fix(length(gaotong)/2); %延迟时间
bitstream1=[];
LL=N; %每个bit的抽样点数 i=IN1 +LL/2;
while (i<=length(signal3)) %判决
bitstream1=[bitstream1,signal3(i)>=0.5]; i=i+LL; end bitstream1 figure(5) subplot(3,1,1);
plot(1:length(signal1),signal1);title('Wave of receiving terminal(including noise)');grid on; subplot(3,1,2);
plot(1:length(signal2),signal2);title('After Passing HPF');grid on; subplot(3,1,3);
plot(1:length(signal3),signal3);title('After Passing LPF');grid on;
signal4=filter(daitong,1,signal1); %通过BPF得到低频分量 signal5=abs(signal4); %整流
signal5=filter(lowpass,1,signal5); %通过LPF,形成包络
IN2=fix(length(lowpass)/2)+fix(length(daitong)/2); %延迟时间 bitstream2=[];
LL=N; %每个bit的的抽样点数 i=IN2 +LL/2;
while (i<=length(signal5)) %判决
bitstream2=[bitstream2,signal5(i)>=0.5]; i=i+LL;
'.
.
end bitstream2 figure(6) subplot(3,1,1);
plot(1:length(signal1),signal1);title('Wave of receiving terminal(including noise)');grid on; subplot(3,1,2);
plot(1:length(signal4),signal4);title('After Passing BPF');grid on; subplot(3,1,3);
plot(1:length(signal5),signal5);title('After Passing LPF');grid on;
for i=1:min(length(bitstream1),length(bitstream2)) %判决 if(bitstream1(i)>bitstream2(i)) bitstream(i)=1; else
bitstream(i)=0; end end bitstream
bit=[]; %接收端波形 for i=1:length(bitstream) if bitstream(i)==0 bit1=zeros(1,N); else
bit1=ones(1,N); end
bit=[bit,bit1]; end figure(7)
plot(bit),title('binary of receiving terminal'),grid on; axis([0,N*length(bitstream),-2.5,2.5]); end
CheckRatePe代码
function PeWrong=CheckRatePe(signal1,signal2,s) rights=0; wrongs=0; for ki=1:s-2
if(signal1(ki)==signal2(ki)) rights=rights+1; else
wrongs=wrongs+1;
'.
基于MATLAB仿真的数字信号调制的性能比较和分析
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)