[問題] BPSK調變MATLAB程式模擬疑問
我寫了以下一段matlab程式碼來畫出BPSK訊號的波形,顯示的波形中,
可以看出傳送bit 1 與 bit 0有相位差180度的差異,看起來沒什麼問題,
於是我想用計算BER來再次確認是否程式有誤。
在AWGN通道下,當SNR_db=4時,合理BER應該為1%而SNR_dB=7時,應為0.1%,
但我測試時,BER大多都維持0,僅在SNR非常差的情況(小於-20),
BER才有0.1%左右,想請教是否有人能幫我檢察看看或是提供一些意見,謝謝。
for kk=1:1000
bitstream=[1 0];
d=0.01;
Es=1; Ts=1; fc=2; tc=[0:d:0.99];
n=1;
symbolbits=1;
NRZ=2*bitstream-1;
carrier=sqrt(2/Ts)*cos(2*pi*fc*tc);
for i=1:symbolbits:length(bitstream)
s(1,(n-1)*length(tc)+1:n*length(tc))=NRZ(i)*carrier;
n=n+1;
end
SNR=4; snr=10^(SNR/10); E=sum(abs(s).^2)/length(s);
N0=E/snr;
noise=sqrt(N0)*randn(1,length(s));
z=s+noise;
%% coherent detection
for i=1:length(z)/length(tc)
Q(1,(i-1)*length(tc)+1:i*length(tc))=z((i-1)*length(tc)+1:i*length(tc)).*carrier;
end
integral=[];
for i=1:2
integral(1,i)=trapz(Q((i-1)*100+1:i*100));
end
detect=integral>0;
ber(1,kk)=sum(detect~=bitstream)/length(bitstream);
end
final_ber=sum(ber)/1000;
figure(1)
time=[0:d:1.99];
subplot(2,1,1); plot(time,s);
subplot(2,1,2); plot(time,z);
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.166.129.144
※ 文章網址: https://www.ptt.cc/bbs/comm_and_RF/M.1545563246.A.88F.html
推
12/30 11:04,
5年前
, 1F
12/30 11:04, 1F
→
12/30 23:32,
5年前
, 2F
12/30 23:32, 2F
→
12/30 23:32,
5年前
, 3F
12/30 23:32, 3F
→
12/30 23:32,
5年前
, 4F
12/30 23:32, 4F
→
12/31 00:41,
5年前
, 5F
12/31 00:41, 5F
→
12/31 00:41,
5年前
, 6F
12/31 00:41, 6F
→
12/31 00:41,
5年前
, 7F
12/31 00:41, 7F
推
01/04 09:49,
6年前
, 8F
01/04 09:49, 8F
→
01/04 09:49,
6年前
, 9F
01/04 09:49, 9F
→
01/04 09:49,
6年前
, 10F
01/04 09:49, 10F
→
01/13 18:17,
6年前
, 11F
01/13 18:17, 11F
→
01/13 18:17,
6年前
, 12F
01/13 18:17, 12F
→
01/13 18:29,
6年前
, 13F
01/13 18:29, 13F
→
01/13 18:29,
6年前
, 14F
01/13 18:29, 14F
→
01/13 18:29,
6年前
, 15F
01/13 18:29, 15F
→
01/13 18:32,
6年前
, 16F
01/13 18:32, 16F
→
01/13 18:32,
6年前
, 17F
01/13 18:32, 17F
→
01/13 18:32,
6年前
, 18F
01/13 18:32, 18F
推
01/13 19:14,
6年前
, 19F
01/13 19:14, 19F
→
01/13 19:16,
6年前
, 20F
01/13 19:16, 20F
→
01/13 19:17,
6年前
, 21F
01/13 19:17, 21F
→
01/13 19:19,
6年前
, 22F
01/13 19:19, 22F
推
01/13 19:24,
6年前
, 23F
01/13 19:24, 23F
→
01/13 19:25,
6年前
, 24F
01/13 19:25, 24F
→
01/13 19:25,
6年前
, 25F
01/13 19:25, 25F
→
01/13 19:25,
6年前
, 26F
01/13 19:25, 26F
→
01/13 21:24,
6年前
, 27F
01/13 21:24, 27F
→
01/13 21:24,
6年前
, 28F
01/13 21:24, 28F
→
01/13 21:24,
6年前
, 29F
01/13 21:24, 29F
→
01/13 21:24,
6年前
, 30F
01/13 21:24, 30F
→
01/13 21:25,
6年前
, 31F
01/13 21:25, 31F
→
01/13 21:25,
6年前
, 32F
01/13 21:25, 32F
推
01/13 23:53,
6年前
, 33F
01/13 23:53, 33F
→
01/13 23:54,
6年前
, 34F
01/13 23:54, 34F
→
01/13 23:55,
6年前
, 35F
01/13 23:55, 35F