?? fsk調制解調matlab源代碼.txt
字號:
FSK調制解調MATLAB源代碼
FSK調制解調MATLAB源代碼2007-08-31 19:50function FSK
Fc=10; %載頻
Fs=40; %系統采樣頻率
Fd=1; %碼速率
N=Fs/Fd;
df=10;
numSymb=25;%進行仿真的信息代碼個數
M=2; %進制數
SNRpBit=60;%信噪比
SNR=SNRpBit/log2(M);
seed=[12345 54321];
numPlot=15;
%產生25個二進制隨機碼
x=randsrc(numSymb,1,[0:M-1]);%產生25個二進制隨機碼
figure(1)
stem([0:numPlot-1],x(1:numPlot),'bx');
title('二進制隨機序列')
xlabel('Time');
ylabel('Amplitude');
%調制
y=dmod(x,Fc,Fd,Fs,'fsk',M,df);
numModPlot=numPlot*Fs;
t=[0:numModPlot-1]./Fs;
figure(2)
plot(t,y(1:length(t)),'b-');
axis([min(t) max(t) -1.5 1.5]);
title('調制后的信號')
xlabel('Time');
ylabel('Amplitude');
%在已調信號中加入高斯白噪聲
randn('state',seed(2));
y=awgn(y,SNR-10*log10(0.5)-10*log10(N),'measured',[],'dB');%在已調信號中加入高斯白噪聲
figure(3)
plot(t,y(1:length(t)),'b-');%畫出經過信道的實際信號
axis([min(t) max(t) -1.5 1.5]);
title('加入高斯白噪聲后的已調信號')
xlabel('Time');
ylabel('Amplitude');
%相干解調
figure(4)
z1=ddemod(y,Fc,Fd,Fs,'fsk/eye',M,df);
title('相干解調后的信號的眼圖')
%帶輸出波形的相干M元頻移鍵控解調
figure(5)
stem([0:numPlot-1],x(1:numPlot),'bx');
hold on;
stem([0:numPlot-1],z1(1:numPlot),'ro');
hold off;
axis([0 numPlot -0.5 1.5]);
title('相干解調后的信號原序列比較')
legend('原輸入二進制隨機序列','相干解調后的信號')
xlabel('Time');
ylabel('Amplitude');
%非相干解調
figure(6)
z2=ddemod(y,Fc,Fd,Fs,'fsk/eye/noncoh',M,df);
title('非相干解調后的信號的眼圖')
%帶輸出波形的非相干M元頻移鍵控解調
figure(7)
stem([0:numPlot-1],x(1:numPlot),'bx');
hold on;
stem([0:numPlot-1],z2(1:numPlot),'ro');
hold off;
axis([0 numPlot -0.5 1.5]);
title('非相干解調后的信號')
legend('原輸入二進制隨機序列','非相干解調后的信號')
xlabel('Time');
ylabel('Amplitude');
%誤碼率統計
[errorSym ratioSym]=symerr(x,z1);
figure(8)
simbasebandex([0:1:5]);
title('相干解調后誤碼率統計')
[errorSym ratioSym]=symerr(x,z2);
figure(9)
simbasebandex([0:1:5]);
title('非相干解調后誤碼率統計')
%濾除高斯白噪聲
Delay=3;R=0.5;PropD=0; %滯后3s
[yf,tf]=rcosine(Fd,Fs,'fir',R,Delay); %升余弦函數
[yo2,to2]=rcosflt(y,Fd,Fs,'filter',yf);
%加入高斯白噪聲后的已調信號和經過升余弦濾波器后的已調信號
t=[0:numModPlot-1]./Fs;
figure(10)
plot(t,y(1:length(t)),'r-');
hold on;
plot(to2,yo2,'b-');
hold off;
axis([0 30 -1.5 1.5]);
xlabel('Time');
ylabel('Amplitude');
legend('加入高斯白噪聲后的已調信號','經過升余弦濾波器后的已調信號')
title('升余弦濾波前后波形比較')
eyediagram(yo2,N);%眼圖
title('加入高斯白噪聲后的已調信號的眼圖')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -