Advertisement
makispaiktis

Eigenbeamforming

Feb 24th, 2022
798
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clc
  2. clear all
  3.  
  4. % Data
  5. M = 2;
  6. N = 3;
  7. limit1 = 100;
  8. limit2 = 400;
  9. paronomastis = 1000;
  10. H = createH(M, N, limit1, limit2, paronomastis)
  11. if M <= N
  12.     A = H * H';
  13. else
  14.     A = H' * H;
  15. end
  16.  
  17. % SVD process
  18. [U, L, V] = svd(A);
  19. bitstream = createMessage(M, N)        % Bitstream contains 0's and 1's
  20. % BPSK Modulation
  21. x = 2 * bitstream - 1
  22.  
  23. % Confirmation
  24. % 1. Precoding (*V)
  25. x_send = V * x
  26. % 2. Channel
  27. y_receive = A * x_send
  28. % 3. Premultiplication(*U')
  29. y = U' * y_receive
  30. % 4. MLD in modulation
  31. x_guess = zeros(length(y), 1);
  32. for k = 1:length(x_guess)
  33.     if real(y(k)) > 0
  34.         x_guess(k) = 1;
  35.     elseif real(y(k)) < 0
  36.         x_guess(k) = -1;
  37.     else
  38.         x_guess(k) = (-1) ^ randi([0 1]);
  39.     end
  40. end
  41. x_guess
  42. bitstream_guess = 0.5 * (x_guess + 1)
  43. errors = sum(abs(bitstream - bitstream_guess))
  44.  
  45.  
  46. % Auxiliary functions
  47. function H = createH(M, N, limit1, limit2, paronomastis)
  48.     H = zeros(M, N);
  49.     for k = 1:M
  50.         for j =1:N
  51.             x = unifrnd(limit1, limit2) / paronomastis;
  52.             y = unifrnd(limit1, limit2) / paronomastis;
  53.             H(k, j) = x + y*i;
  54.         end
  55.     end
  56. end
  57.  
  58. function message = createMessage(M, N)
  59.     message = zeros(min(M, N), 1);
  60.     for k = 1:length(message)
  61.         message(k) = randi([0 1]);
  62.     end
  63. end
Advertisement
RAW Paste Data Copied
Advertisement