Advertisement
basyair07

untitle2.m

Oct 7th, 2024
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.03 KB | None | 0 0
  1. % Analisis Efisiensi Spektral
  2. % parameter Sistem
  3. K = [10 20 30 40 50]; % Variasi jumlah pengguna
  4. Ns = 500; % jumlah sampel
  5. M_bs = [100 200 300 400 500]; % Variasi jumlah antena relay
  6. N = 1; % Jumlah antena pengguna (single antenna users)
  7. SNR_dB = [-10:5:10]; % Variasi SNR dalam dB
  8. sigma2 = 1; % Variansi noise
  9. tau = 0.8; % Faktor untuk imperfect CSI
  10. num_trials = 100; % Jumlah untuk rata-rata
  11.  
  12. % Inisialisasi variabel untuk menyimpan efisiensi spektral
  13. SE_ul = zeros(length(M_bs), length(SNR_dB));
  14. SE_dl = zeros(length(M_bs), length(SNR_dB));
  15.  
  16. % Simulasi untuk setiap jumlah antena di relay dan SNR
  17. for m_idx = 1:length(M_bs)
  18.     M = M_bs(m_idx); % Jumlah antena relay
  19.    
  20.     for snr_idx = 1:length(SNR_dB)
  21.         % Konversi SNR dari dB ke linear
  22.         SNR = 10^(SNR_dB(snr_idx)/10);
  23.        
  24.         % Konversi SNR ke skala linear
  25.         P_ul = SNR; % Daya uplink
  26.         P_dl = SNR; % Daya downlink
  27.        
  28.         % Simulasi untuk rata-rata
  29.         for trial = 1:num_trials
  30.             % Model Kanal Rayleigh Fading (uplink dan downlink)
  31.             H_ul = (randn(M, K(m_idx)) + 1i*randn(M, K(m_idx)))/sqrt(2); % Uplink channel
  32.             H_dl = (randn(K(m_idx), M) + 1i*randn(K(m_idx), M))/sqrt(2); % Downlink channel
  33.            
  34.             % Imperfect CSI (Noise ditambahkan ke perfect CSI) (Estimasi channel)
  35.             H_ul_imp = tau * H_ul + sqrt(1 - tau^2) * (randn(M, K(m_idx)) + 1i*randn(M, K(m_idx)))/sqrt(2);
  36.             H_dl_imp = tau * H_dl + sqrt(1 - tau^2) * (randn(K(m_idx), M) + 1i*randn(K(m_idx), M))/sqrt(2);
  37.            
  38.             % Deteksi Uplink dengan MMSE
  39.             W_ul_MMSE = inv(H_ul_imp' * H_ul_imp + (sigma2 / P_ul) * eye(K(m_idx))) * H_ul_imp'; % MMSE Detection
  40.             SINR_ul = diag(W_ul_MMSE * H_ul * H_ul' * W_ul_MMSE') / sigma2; % SINR uplink
  41.            
  42.             % Precoding Downlink dengan RZF
  43.             alpha = 1 / SNR; % Regularization parameter
  44.             W_dl_RZF = H_dl_imp' * inv(H_dl_imp * H_dl_imp' + alpha * eye(K(m_idx))); % RZF Precoding
  45.             SINR_dl = diag(H_dl * W_dl_RZF * W_dl_RZF' * H_dl') / sigma2; % SINR downlink
  46.            
  47.             % Perhitungan Efisiensi Spektral
  48.             SE_ul(m_idx, snr_idx) = SE_ul(m_idx, snr_idx) + sum(log2(1 + SINR_ul)) / num_trials;
  49.             SE_dl(m_idx, snr_idx) = SE_dl(m_idx, snr_idx) + sum(log2(1 + SINR_dl)) / num_trials;
  50.         end
  51.     end
  52. end
  53.  
  54. % Plot Hasil Efisiensi Spektral Uplink
  55. figure;
  56. hold on;
  57. for m_idx = 1:length(M_bs)
  58.     plot(SNR_dB, SE_ul(m_idx, :), 'LineWidth', 2, 'DisplayName', ['M = ' num2str(M_bs(m_idx))]);
  59. end
  60. title('Efisiensi Spektral Uplink vs SNR');
  61. xlabel('SNR (dB)');
  62. ylabel('Efisiensi Spektral (bps/Hz)');
  63. legend show;
  64. grid on;
  65. hold off;
  66.  
  67. % Plot Hasil Efisiensi Spektral Downlink
  68. figure;
  69. hold on;
  70. for m_idx = 1:length(M_bs)
  71.     plot(SNR_dB, SE_dl(m_idx, :), 'LineWidth', 2, 'DisplayName', ['M = ' num2str(M_bs(m_idx))]);
  72. end
  73. title('Efisiensi Spektral Downlink vs SNR');
  74. xlabel('SNR (dB)');
  75. ylabel('Efisiensi Spektral (bps/Hz)');
  76. legend show;
  77. grid on;
  78. hold off;
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement