SHARE
TWEET

Untitled

a guest Oct 23rd, 2015 118 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. num_bits = 1e6;
  2. num_symb = num_bits / 2;
  3. symb_energy = 1;
  4. A_qpsk = sqrt(symb_energy);
  5. A_zero = sqrt(4/3*symb_energy);
  6.  
  7. qpsk_alphabet = zeros(4, 1);
  8. qpsk_alphabet(1) = A_qpsk * exp(1i*pi/4);
  9. qpsk_alphabet(2) = A_qpsk * exp(1i*3*pi/4);
  10. qpsk_alphabet(3) = A_qpsk * exp(1i*5*pi/4);
  11. qpsk_alphabet(4) = A_qpsk * exp(1i*7*pi/4);
  12.  
  13. zero_alphabet = zeros(4, 1);
  14. zero_alphabet(1) = 0;
  15. zero_alphabet(2) = A_zero;
  16. zero_alphabet(3) = A_zero * exp(1i*2*pi/3);
  17. zero_alphabet(4) = A_zero * exp(1i*4*pi/3);
  18.  
  19. symbols = randi(4, num_symb, 1);
  20. qpsk_sig = zeros(num_symb, 1);
  21. zero_sig = zeros(num_symb, 1);
  22.  
  23. snr_vec = 0:30; % in dB;
  24. serr_vec_qpsk = zeros(size(snr_vec));
  25. serr_vec_zero = zeros(size(snr_vec));
  26.  
  27. % Map
  28. for k=1:num_symb
  29.     qpsk_sig(k) = qpsk_alphabet(symbols(k));
  30.     zero_sig(k) = zero_alphabet(symbols(k));
  31. end
  32.  
  33. % plot(real(qpsk_sig), imag(qpsk_sig), '.');
  34. % hold on;
  35. % plot(real(zero_sig), imag(zero_sig), '.');
  36. % grid on;
  37. % xlim([-1.5 1.5]);
  38. % ylim([-1.5 1.5]);
  39.  
  40. for six = 1:numel(snr_vec)    
  41.     % Add noise  
  42.     snr = snr_vec(six);
  43.     noise_energy = symb_energy * 10^(-snr/10);
  44.     noise = sqrt(noise_energy/2) .* (randn(num_symb, 1) + 1i*randn(num_symb, 1));
  45.     qpsk_sig_rx = qpsk_sig + noise;
  46.     zero_sig_rx = zero_sig + noise;
  47.    
  48.     % figure;
  49.     % plot(real(qpsk_sig_rx), imag(qpsk_sig_rx), '.');
  50.     % hold on;
  51.     % plot(real(zero_sig_rx), imag(zero_sig_rx), '.');
  52.     % grid on;
  53.     % xlim([-1.5 1.5]);
  54.     % ylim([-1.5 1.5]);
  55.    
  56.     % Demap
  57.     symbols_qpsk_rx = zeros(size(symbols));
  58.     symbols_zero_rx = zeros(size(symbols));
  59.     for k=1:num_symb
  60.         qdist = abs(qpsk_sig_rx(k).*ones(4, 1) - qpsk_alphabet).^2;
  61.         [~, ix] = min(qdist);
  62.         symbols_qpsk_rx(k) = ix;
  63.        
  64.         zdist = abs(zero_sig_rx(k).*ones(4, 1) - zero_alphabet).^2;
  65.         [~, ix] = min(zdist);
  66.         symbols_zero_rx(k) = ix;
  67.     end
  68.     num_serr_qpsk = sum( symbols ~= symbols_qpsk_rx );
  69.     num_serr_zero = sum( symbols ~= symbols_zero_rx );
  70.     serr_rate_qpsk = num_serr_qpsk / num_symb;
  71.     serr_rate_zero = num_serr_zero / num_symb;
  72.     serr_vec_qpsk(six) = serr_rate_qpsk;
  73.     serr_vec_zero(six) = serr_rate_zero;
  74.     fprintf('%d dB: QPSK/ZERO: %f / %f\n', snr, serr_rate_qpsk, serr_rate_zero);
  75. end
  76.  
  77. figure;
  78. semilogy(snr_vec, serr_vec_qpsk);
  79. hold on;
  80. semilogy(snr_vec, serr_vec_zero);
  81. legend('QPSK', 'Proposed');
  82. grid on;
  83. ylabel('symbol error rate');
  84. xlabel('SNR in dB');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top