Chuong Trinh

2

Click here to load reader

Transcript of Chuong Trinh

Page 1: Chuong Trinh

% written by Hung Nguyen-Le; Nov. 28, 2010% This program provides BER performance of Digital modulations over% wireless/wireline channelsclose all;clear all;%============ System settings in the simulation============================M = 4; %Modulation level of M-ary quadrature amplitude modulation (MQAM), e.g., BPSK -> M=2; QPSK -> M =4; ......B = log2(M); % number of bits to be conveyed by one MQAM complex symbolN = 1e3; % number of MQAM complex symbols per one transmission burst/framenum_trials = 10; % number of trials, e.g., the number of bursts to be transmitted in the simulationSNR = [0:5:20]; % signal-to-noise ratios (SNRs) are considered in the simulation%-------------------------------------------------------------------------sig_power = signal_power_computation(M); % average MQAM symbol energy; ***Please extend to the case of M >2BER_AWGN = zeros(1,length(SNR)); % contain bit error rate values of the simulation under AWGN channelsBER_fading = zeros(1,length(SNR));BER_noCSI = zeros(1,length(SNR));

for index = 1:length(SNR) No = sig_power/( 10^( SNR(index)/10 ) ); % noise sample variance or noise power for loop = 1:num_trials % Bit generation at transmitter bit_seq = rand(1,B*N) > .5; % uncoded or coded binary bits to be transmitted

bit_noise+rand(1,B*N)<0.1;% Chuoi Bit gay nhieu den mang nhanh thuc % Digital modulation [tx_sig] = MQAM_modulator( reshape(bit_seq,B,N) ); % transmitted signal

[tx_noise]=MQAM_modulator( reshape(bit_noise,B,N) ); % transmitted noise

% over AGWN channel (e.g.,wireline channels) noise_samples = sqrt(No/2)*( randn(1,N) + j*randn(1,N) ); % AWGN noise samples rx_sig_AWGN = tx_sig +tx_noise+noise_samples; % received signal over AWGN channels [reco_bit_AWGN] = MQAM_Demodulator_AWGN(rx_sig_AWGN,M); %Bit detection under MQAM modulation %-----------------***Please extend to the case of M >2-------------

% over fading channels (e.g., wireless channels), assuming perfect channel estimation has % been established by existing techniques, i.e., h is perfectly known at the receiver h = sqrt(1/2)*( randn(1,N) + j*randn(1,N) ); % Generation of Rayleigh fading gains rx_sig_fading = h.*tx_sig +tx_noise+ noise_samples; % received signal over fading channels [reco_bit_fading] = MQAM_Demodulator(rx_sig_fading,h,M);% Bit detection under MQAM modulation over wireless channels

% Consider the case of wireless channels without channel state % information (CSI) at receiver, i.e., ignore the presence of fading gains h in the received signal [reco_bit_noCSI] = MQAM_Demodulator_AWGN(rx_sig_fading,M); %Bit detectio

Page 2: Chuong Trinh

n under MQAM modulation %----*** Please consider the case of multipath fading where channel impluse response is {h_0, h_1} ***

% Count the number of error bits occuring BER_AWGN(index) = BER_AWGN(index) + sum( abs(bit_seq - reco_bit_AWGN) ); BER_fading(index) = BER_fading(index) + sum( abs(bit_seq - reco_bit_fading) ); BER_noCSI(index) = BER_noCSI(index) + sum( abs(bit_seq -reco_bit_noCSI) ); endendBER_noCSI = BER_noCSI/(B*N*num_trials)BER_fading = BER_fading/(B*N*num_trials)BER_AWGN = BER_AWGN/(B*N*num_trials)

figure(1)semilogy(SNR,BER_noCSI,'k^--','LineWidth',2);hold on;semilogy(SNR,BER_fading,'ro-','LineWidth',2);hold on;semilogy(SNR,BER_AWGN,'s-','LineWidth',2);hold on;

xlabel('SNR (dB)');ylabel('Bit error rate (BER)');legend( 'Wireless transmission without CSI',... 'Wireless transmission with CSI',... 'Wireline transmission, i.e., AWGN channels'); figure(2)subplot(3,1,1);plot(real(tx_sig),imag(tx_sig),'ro','LineWidth',2);xlim([min(real(rx_sig_fading)) max(real(rx_sig_fading))]);ylim([min(imag(rx_sig_fading)) max(imag(rx_sig_fading))]);legend( 'MQAM constellation at transmitter');

subplot(3,1,2);plot( real(rx_sig_AWGN),imag(rx_sig_AWGN),'o');xlim([min(real(rx_sig_fading)) max(real(rx_sig_fading))]);ylim([min(imag(rx_sig_fading)) max(imag(rx_sig_fading))]);legend( 'MQAM constellation at receiver over AWGN channels');

subplot(3,1,3);plot( real(rx_sig_fading),imag(rx_sig_fading),'ko');xlim([min(real(rx_sig_fading)) max(real(rx_sig_fading))]);ylim([min(imag(rx_sig_fading)) max(imag(rx_sig_fading))]);legend( 'MQAM constellation at receiver over wireless channels');