目录
💥1 概述
📚2 运行结果
🎉3 参考文献
👨💻4 Matlab代码
💥1 概述
该项目的目的是介绍单载波通信系统的模拟。
📚2 运行结果
主函数部分代码:
%% clear all WorkSpace Variables and Command Window clc; clear ; close all; %% initialization Bits_Number = 1.2e5; % number of bits to be generated SNR_max_value = 10; %% Generating the data bits Bit_Stream = randi([0 1],1,Bits_Number); %% BPSK Modulation %initializations needed for Simulation of BPSK BPSK_Eb = ((1 +1)/ 2) / 1; %Calculating Eb of BPSK modulation BPSK_BER_Theo = zeros(1,SNR_max_value); %Vector to store the theortical BER for different SNR channel BPSK_BER = zeros(1,SNR_max_value); %Vector to store the calculated BER for different SNR channel %Mapper BPSK_symbolStream = 2 * Bit_Stream - 1; %The sent symbol is either 1 or -1 %Channel (AWGN) BPSK_channelNoise = zeros(length(Bit_Stream),SNR_max_value); %Matrix to store the noise in each channel BPSK_No = zeros(1,SNR_max_value + 1); %Calculating No of the channel for different SNR for SNR_dB = 1 : (SNR_max_value + 1) %Generating different noise vector for different channels with different SNR noise = randn(1,length(Bit_Stream)); BPSK_No(SNR_dB) = BPSK_Eb/10.^((SNR_dB-1)/10); BPSK_channelNoise(:,SNR_dB) = noise * sqrt (BPSK_No(SNR_dB)/2); %scale the noise. end %Demapper BPSK_demappedSymbol = zeros(1,length(Bit_Stream)); %Vector to store the demapped stream for SNR_dB = 1 : (SNR_max_value + 1) BPSK_DataRx = BPSK_symbolStream + BPSK_channelNoise(:,SNR_dB)'; %Recieved Data %Demapping the recieved symbol stream for each channel for counter = 1 : Bits_Number if(BPSK_DataRx(1,counter) > 0) BPSK_demappedSymbol(1,counter) = 1; else BPSK_demappedSymbol(1,counter) = 0; end end [N_BER_BPSK,BPSK_BER(SNR_dB)] = symerr(BPSK_demappedSymbol,Bit_Stream); %Calculated BER BPSK_BER_Theo(SNR_dB)= 0.5 * erfc(sqrt(1/BPSK_No(SNR_dB))); %Theoritical BER end %Plotting constillation of BPSK figure(1) subplot(2,2,1,'LineWidth',3) plot(real(BPSK_DataRx),imag(BPSK_DataRx),'r*',real(1),imag(0),'k.',real(-1),imag(0),'k.'); title('BPSK Modulation for SNR = 10') %Plotting BER figure(2) subplot(2,2,1,'LineWidth',3) EbN0_dB = 1:1:(SNR_max_value + 1) ; %Plotting theoritical BER semilogy((EbN0_dB - 1),BPSK_BER_Theo,'--') %Plotting calculated BER hold on semilogy((EbN0_dB - 1),BPSK_BER,'-') grid on ylabel('BER') xlabel('E_b/N_0') title('Bit Error Rate for BPSK') legend('Theoretical','Calculated'); %% QPSK %initializations needed for Simulation of BPSK QPSK_Eb = ((4 * 2) / 4 ) / 2; QPSK_BER_Theo = zeros(1,SNR_max_value); %Vector to store the theortical BER for different SNR channel QPSK_BER = zeros(1,SNR_max_value); %Vector to store the calculated BER for different SNR channel QPSK_BER_encode2 = zeros(1,SNR_max_value); %Vector to store the calculated BER for different SNR channel %Mapper %Grouping the binary data into groups of 2 bits QPSK_reshaped_binary_data = reshape(Bit_Stream,2,[])'; %Mapping the input data to QPSK symbols grey encoded % 0 0 -> -1-1i % 0 1 -> -1+1i % 1 0 -> 1-1i % 1 1 -> 1+1i QPSK_map = [-1-1i, -1+1i, 1-1i, 1+1i]; % 0 0 -> -1-1i % 0 1 -> -1+1i % 1 0 -> 1+1i % 1 1 -> 1-1i QPSK_map_encode2 = [-1-1i, -1+1i,1+1i, 1-1i]; %The bi2de function is used to convert the binary data to decimal values, %which are then used as indices to look up the corresponding QPSK symbol in the mapping table QPSK_data = QPSK_map(bi2de(QPSK_reshaped_binary_data,'left-msb')+1); QPSK_data_encode2 = QPSK_map_encode2(bi2de(QPSK_reshaped_binary_data,'left-msb')+1); %Channel (AWGN) QPSK_channelNoise_real = zeros(length(Bit_Stream)/2,SNR_max_value); %Matrix to store the real noise in each channel QPSK_channelNoise_complex = zeros(length(Bit_Stream)/2,SNR_max_value); %Matrix to store the complex noise in each channel QPSK_No = zeros(1,SNR_max_value + 1); %Calculating No of the channel for different SNR for SNR_dB = 1 : (SNR_max_value + 1) %Generating different noise vector for different channels with different SNR QPSK_No(SNR_dB) = QPSK_Eb/10.^((SNR_dB-1)/10); noise_I = randn(1,length(Bit_Stream)/2); QPSK_channelNoise_real(:,SNR_dB) = noise_I * sqrt (QPSK_No(SNR_dB)/2); %scale the noise. noise_Q = randn(1,length(Bit_Stream)/2); QPSK_channelNoise_complex(:,SNR_dB) = noise_Q * sqrt (QPSK_No(SNR_dB)/2); %scale the noise. end
🎉3 参考文献
[1]刘洋. 单载波通信系统中的频域均衡技术研究[D].北京邮电大学,2017.
部分理论引用网络文献,若有侵权联系博主删除。