在MATLAB中显示BPSK信号波形

时间:2018-12-19 06:31:03

标签: matlab signal-processing serial-communication

我想显示通过AWGN通道的信号波形,因此我遵循这些框图并参考了该网站,然后完成了该程序。

enter image description here enter image description here

http://drmoazzam.com/matlab-code-bpsk-modulation-and-demodulation-with-explanation/

我发送了一个比特流1和0,只有两个比特。设置每位符号能量Es = 1,比特率Ts = 1,载波频率fc = 2。我将比特流编码为双线性不归零格式,然后将其调制为BPSK信号。

当接收到信号时,使用相干检测对其进行解调。 要验证我的程序(从显示波形看似乎是正确的。调制1和0之后,两个波形的相位彼此偏移180º,如下图所示。),我计算了BER。 BER随SNR变化。但是,我将SNR = 1dB设置为BER仍为0(SNR = 1,finalber = 0)。这没有任何意义。我不知道为什么会这样。谁可以帮助我检查?谢谢

enter image description here

clc;
clear all;
% BPSK trapz

for kk=1:1000
bitstream=[1 0 ];
%% modulate: BPSK
Es=1;% symbol energy per bit
Ts=1; %Bit rate is assumed to be 1 bit/s;
fc=2; % carrier frequency
d=0.01; % sampled interval
tc=[0:d:0.99];
n=1;
symbolbits=1; % how many bits in a symbol, BPSK=1,QPSK=2
NRZ=2*bitstream-1; % non-return-to-zero line code,bit 1 ->1 , bit 0 ->-1
for i=1:symbolbits:length(bitstream)
    s(1,(n-1)*length(tc)+1:n*length(tc))=NRZ(i)*sqrt(2/Ts)*cos(2*pi*fc*tc);
    n=n+1;
end

%% through AWGN channnel
SNR=20; % SNR in dB
snr=10^(SNR/10);
E=sum(abs(s).^2)/length(s); %signal energy
N0=E/snr; % noise spectral density
noise=sqrt(N0)*(randn(1,length(s))); % s is real value signal
received=s+noise;
%% coherent detection
for i=1:length(received)/length(tc)
    Qr(1,(i-1)*length(tc)+1:i*length(tc))=received((i-1)*length(tc)+1:i*length(tc)).*(sqrt(2/Ts)*cos(2*pi*fc*tc));
end
m=1;
y=[];
time=[0:d:1.99];
for i=1:2
 y(1,i)=trapz(time((i-1)*100+1:i*100),Qr((i-1)*100+1:i*100));
end
detected=y;
for i=1:length(detected)
    if detected(i)>0
        demod(i)=1;
    else
        demod(i)=0;
    end
end
ber(1,kk)=sum(demod~=bitstream)/length(bitstream);
end
finalber=sum(ber)/1000;

figure(1)
time=[0:d:1.99];
subplot(3,1,1); plot(time,s); title('transmitted BPSK signal')
subplot(3,1,2); plot(time,received); title('received BPSK signal')
subplot(3,1,3); plot(time,Qr)

0 个答案:

没有答案