Академический Документы
Профессиональный Документы
Культура Документы
学号:2017290005
代码:
clear all
nSamp = 8; %Sampling points of rectangular pulse
numSymb = 10000; %Number of symbols transmitted under each SNR
fs = numSymb*nSamp;
fd = 10; % dopler
t = 0:1/fs:1-1/fs;
for ii=1:length(SNR)
msg=randsrc(1,numSymb,[0:3]); % generate send symbol
msg_gr=grayencod(msg+1); %Gray coded mapping
msg_tx=pskmod(msg_gr,M); %QPSK modulation
msg_tx=rectpulse(msg_tx,nSamp); %rectangular pulse shaping
h=rayleighchan(1/fs,fd);
msg_tx1=filter(h,msg_tx);
scatterplot(msg_tx(1:100));
% Generate constellation
% Draw the constellation of the transmitted signal
title('Transmitted Signal Constellation')
xlabel('In-phase component')
ylabel('Orthogonal component')
scatterplot(msg_rx(1:100));
%Draw the constellation of the received signal
title('Received signal constellation')
xlabel('In-phase component')
ylabel('Orthogonal component')
scatterplot(msg_rx1(1:100));
% Draw the constellation of the received signal
title('Received signal constellation')
xlabel('In-phase component')
ylabel('Orthogonal component')
figure
semilogy(SNR,BER,'-ro',SNR,SER,'-r*',SNR,BER1,'-r+',SNR,SER1,'-r^');
% Draw BER and SNR changes with SNR Of the curve
legend('AWGN BER','AWGN SER','AWGN+Rayleigh BER','AWGN+Rayleigh SER')
% creates a legend with descriptive labels for each plotter data
series
title('QPSK performance under AWGN channel')
%performance of QPSK in AWGN channel & AWGN+Rayleigh channel
xlabel('Signal to Noise Ratio?dB?') % SNR(dB)
ylabel('Symbol error rate and bit error rate')
% Bit error ratio & Symbol error ratio
As can be seen from the above figure, as the SNR increases,
the BER and SER of QPSK both decrease, and the BER is less
than the corresponding SER, which is consistent with the actual
situation It shows that the simulation results are correct