Advertisement
makispaiktis

Wireless Communications - NOMA

Feb 1st, 2022 (edited)
2,349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.23 KB | None | 0 0
  1. clc
  2. clear all
  3.  
  4. % Data
  5. h1_2 = 0.06;
  6. h2_2 = 0.1;
  7. rho_dB = 20;
  8. rho = 10^(0.1 * rho_dB);
  9. t_List = 0:0.01:1;
  10. LEN = length(t_List) + 3;
  11. x = zeros(1, LEN);
  12. y = zeros(1, LEN);
  13. % Vectors without t
  14. % x = [0 R1_max R1_max R1_t0 0];
  15. % y = [0 0 R2_t1 R2_max R2_max];
  16. x(1) = 0;
  17. x(LEN) = 0;
  18. y(1) = 0;
  19. y(2) = 0;
  20.  
  21.  
  22. % Calculations
  23. R1_max = log2(1 + rho * h1_2);
  24. R2_max = log2(1 + rho * h2_2);
  25. R1_t1 = log2(1 + h1_2 / (h2_2 + 1/rho));
  26. R2_t0 = log2(1 + h2_2 / (h1_2 + 1/rho));
  27. x(2) = R1_max;
  28. y(LEN) = R2_max;
  29.  
  30. for i = 1:length(t_List)
  31.     t = t_List(i);
  32.     x(i+2) = t * R1_t1 + (1-t) * R1_max;
  33.     y(i+2) = (1-t) * R2_t0 + t * R2_max;
  34. end
  35.  
  36. sum_rate_1 = R1_t1 + R2_max;
  37. sum_rate_2 = R2_t0 + R1_max;
  38. if sum_rate_1 == sum_rate_2
  39.     disp("Sum rate in Time-Sharing line: " + num2str(sum_rate_1));
  40. end
  41.  
  42. % Equation for t
  43. syms t
  44. f1 = t * R1_t1 + (1-t) * R1_max;
  45. f2 = (1-t) * R2_t0 + t * R2_max;
  46. eqn = f1 == f2;
  47. t_eff = vpasolve(eqn, t);
  48. t_eff = sym2poly(t_eff);
  49. f1 = matlabFunction(f1);
  50. R_eq = f1(t_eff);
  51.  
  52. disp("Same rate for R_1 and R_2 in: t_eff = " + (1-t_eff));
  53. disp("R_1 = " + num2str(R_eq) + ", R_2 = " + num2str(R_eq) + ", R_{max} = " + num2str(2*R_eq));
  54. plot(x, y);
  55. title("Capacity Region");
  56. xlabel("R_1");
  57. ylabel("R_2");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement