% Simulation for IRS-aided Communication System
% Parameters
numIDs = 4; % Number of information decoders (IDs)
numERs = 2; % Number of energy receivers (ERs)
numIRS = 64; % Number of IRS reflecting elements
numAntennas = 4; % Number of antennas at the BS
P_bs = 10; % Transmit power at BS (dBm)
noisePower = -80; % Noise power (dBm)
eta = 0.7; % Energy harvesting efficiency
thetaResolution = 2; % Bits for phase shift resolution
% Convert dBm to linear scale
P_bs_linear = 10^((P_bs - 30) / 10);
noisePower_linear = 10^((noisePower - 30) / 10);
% Channel Modeling
H_direct = sqrt(1e-3) * (randn(numIDs, numAntennas) + 1j * randn(numIDs,
numAntennas));
H_IRS = sqrt(1e-4) * (randn(numIRS, numAntennas) + 1j * randn(numIRS,
numAntennas));
G_IRS_ID = sqrt(1e-4) * (randn(numIDs, numIRS) + 1j * randn(numIDs, numIRS));
G_IRS_ER = sqrt(1e-4) * (randn(numERs, numIRS) + 1j * randn(numERs, numIRS));
% IRS Reflection Coefficients
phaseShifts = exp(1j * (0:2^thetaResolution-1) * 2*pi/(2^thetaResolution)); %
Discrete phases
IRS_coefficients = phaseShifts(randi(length(phaseShifts), numIRS, 1));
% Transmit Beamforming (Random)
beamforming_vectors = sqrt(P_bs_linear / numAntennas) * (randn(numAntennas,
numIDs) + 1j * randn(numAntennas, numIDs));
% Received Signals at IDs
effectiveChannel_ID = H_direct + G_IRS_ID * diag(IRS_coefficients) * H_IRS;
receivedPower_ID = abs(effectiveChannel_ID * beamforming_vectors).^2;
SINR_ID = diag(receivedPower_ID) ./ (sum(receivedPower_ID, 2) +
noisePower_linear);
% Received Signals at ERs
effectiveChannel_ER = G_IRS_ER * diag(IRS_coefficients) * H_IRS;
harvestedEnergy_ER = eta * sum(abs(effectiveChannel_ER *
beamforming_vectors).^2, 2);
% Results
disp('SINR for IDs (dB):');
disp(10 * log10(SINR_ID));
disp('Harvested Energy for ERs (mW):');
disp(harvestedEnergy_ER * 1e3);
% Plot Results with improved clarity
figure;
1
% Plot SINR for IDs
bar(10 * log10(SINR_ID), 'FaceColor', [0.2, 0.6, 0.8], 'EdgeColor', 'black',
'LineWidth', 1.5);
title('SINR for IDs', 'FontSize', 14);
xlabel('ID Index', 'FontSize', 12);
ylabel('SINR (dB)', 'FontSize', 12);
grid on;
set(gca, 'FontSize', 12);
set(gca, 'YDir', 'normal');
colorbar;
legend('SINR for IDs', 'Location', 'best');
axis tight;
% Plot Harvested Energy for ERs
figure;
bar(harvestedEnergy_ER * 1e3, 'FaceColor', [0.8, 0.2, 0.4], 'EdgeColor',
'black', 'LineWidth', 1.5);
title('Harvested Energy for ERs', 'FontSize', 14);
xlabel('ER Index', 'FontSize', 12);
ylabel('Energy (mW)', 'FontSize', 12);
grid on;
set(gca, 'FontSize', 12);
colorbar;
legend('Harvested Energy for ERs', 'Location', 'best');
axis tight;
SINR for IDs (dB):
-5.4371
-4.3344
-6.7653
-2.7459
Harvested Energy for ERs (mW):
1.0e-03 *
0.0750
0.1452
2
3
4
Published with MATLAB® R2024b