Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Analisis Efisiensi Spektral
- % parameter Sistem
- K = [10 20 30 40 50]; % Variasi jumlah pengguna
- Ns = 500; % jumlah sampel
- M_bs = [100 200 300 400 500]; % Variasi jumlah antena relay
- N = 1; % Jumlah antena pengguna (single antenna users)
- SNR_dB = [-10:5:10]; % Variasi SNR dalam dB
- sigma2 = 1; % Variansi noise
- tau = 0.8; % Faktor untuk imperfect CSI
- num_trials = 100; % Jumlah untuk rata-rata
- % Inisialisasi variabel untuk menyimpan efisiensi spektral
- SE_ul = zeros(length(M_bs), length(SNR_dB));
- SE_dl = zeros(length(M_bs), length(SNR_dB));
- % Simulasi untuk setiap jumlah antena di relay dan SNR
- for m_idx = 1:length(M_bs)
- M = M_bs(m_idx); % Jumlah antena relay
- for snr_idx = 1:length(SNR_dB)
- % Konversi SNR dari dB ke linear
- SNR = 10^(SNR_dB(snr_idx)/10);
- % Konversi SNR ke skala linear
- P_ul = SNR; % Daya uplink
- P_dl = SNR; % Daya downlink
- % Simulasi untuk rata-rata
- for trial = 1:num_trials
- % Model Kanal Rayleigh Fading (uplink dan downlink)
- H_ul = (randn(M, K(m_idx)) + 1i*randn(M, K(m_idx)))/sqrt(2); % Uplink channel
- H_dl = (randn(K(m_idx), M) + 1i*randn(K(m_idx), M))/sqrt(2); % Downlink channel
- % Imperfect CSI (Noise ditambahkan ke perfect CSI) (Estimasi channel)
- H_ul_imp = tau * H_ul + sqrt(1 - tau^2) * (randn(M, K(m_idx)) + 1i*randn(M, K(m_idx)))/sqrt(2);
- H_dl_imp = tau * H_dl + sqrt(1 - tau^2) * (randn(K(m_idx), M) + 1i*randn(K(m_idx), M))/sqrt(2);
- % Deteksi Uplink dengan MMSE
- W_ul_MMSE = inv(H_ul_imp' * H_ul_imp + (sigma2 / P_ul) * eye(K(m_idx))) * H_ul_imp'; % MMSE Detection
- SINR_ul = diag(W_ul_MMSE * H_ul * H_ul' * W_ul_MMSE') / sigma2; % SINR uplink
- % Precoding Downlink dengan RZF
- alpha = 1 / SNR; % Regularization parameter
- W_dl_RZF = H_dl_imp' * inv(H_dl_imp * H_dl_imp' + alpha * eye(K(m_idx))); % RZF Precoding
- SINR_dl = diag(H_dl * W_dl_RZF * W_dl_RZF' * H_dl') / sigma2; % SINR downlink
- % Perhitungan Efisiensi Spektral
- SE_ul(m_idx, snr_idx) = SE_ul(m_idx, snr_idx) + sum(log2(1 + SINR_ul)) / num_trials;
- SE_dl(m_idx, snr_idx) = SE_dl(m_idx, snr_idx) + sum(log2(1 + SINR_dl)) / num_trials;
- end
- end
- end
- % Plot Hasil Efisiensi Spektral Uplink
- figure;
- hold on;
- for m_idx = 1:length(M_bs)
- plot(SNR_dB, SE_ul(m_idx, :), 'LineWidth', 2, 'DisplayName', ['M = ' num2str(M_bs(m_idx))]);
- end
- title('Efisiensi Spektral Uplink vs SNR');
- xlabel('SNR (dB)');
- ylabel('Efisiensi Spektral (bps/Hz)');
- legend show;
- grid on;
- hold off;
- % Plot Hasil Efisiensi Spektral Downlink
- figure;
- hold on;
- for m_idx = 1:length(M_bs)
- plot(SNR_dB, SE_dl(m_idx, :), 'LineWidth', 2, 'DisplayName', ['M = ' num2str(M_bs(m_idx))]);
- end
- title('Efisiensi Spektral Downlink vs SNR');
- xlabel('SNR (dB)');
- ylabel('Efisiensi Spektral (bps/Hz)');
- legend show;
- grid on;
- hold off;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement