Calculating the H0_LOS & P_rec_dBm and draw it at every new psi & phi values?

1 view (last 30 days)
I am calculating the optical received power via the following two lines of code:
P_r_LOS = P_t.*H0_LOS.*T_s.*G_Con;
P_rec_dBm = 10*log10(P_r_LOS*1000);
The main equation that I deal with is with this line of code:
H0_LOS(r_x,r_y,i_t)= (m+1)*A_det/(2*pi*d_tr^2)*cos(phi)^m*cos(psi);
First, I wanted to try phi = 0 & psi = 0, and it successfully gave me the results, but when I applied phi = 0:5:30 and psi = 0:5:30, it only gave me the results for the last value of phi & psi which is 30.
I want to calculate the received optical power and draw it at every new phi & psi value.
May I get any assistance, please?
close all;
clear variables;
clc;
N_t = 1; % Number of light sources
L=20; W=20; H=3; % Length, width and height of the room (m)
theta_half = 30;
m = -log(2)./log(cosd(theta_half)); % Lambertian order of emission
coord_t = [0 0 0]; % Positions of the light sources
n_t_LED = [0, 0, -1]; n_t_LED = n_t_LED/norm(n_t_LED); % Normalized normal vector of each light source
n_t = repmat(n_t_LED, N_t, 1); % Normalized normal vectors of the light sources
%-------------------------------------%
% LIGHT SOURCES ELECTRICAL PARAMETERS %
%-------------------------------------%
P_LED = 2.84; % Average electrical power consumed by each light source (W)
param_t = {coord_t, n_t, P_LED, m};
A_det = 1e-4; % Photoreceiver sensitive area (m²)
FOV=60*pi/180; % Field-of-view of the photoreceiver
T_s = 1; % Gain of the optical filter (ignore if not used)
index=1.5; % Refractive index of the Rx concentrator/lens (ignore if not used)
G_Con = (index^2)/sin(FOV); % Gain of an optical concentrator; ignore if no lens is used
n_r = [0, 0, 1]; % Normal vector of the photoreceiver
n_r = n_r/norm(n_r); % Normal vector of the photoreceiver (normalized)
step = 0.5; % Distance between each receiving point (m)
X_r = -L/2:step:L/2; % Range of Rx points along x axis
Y_r = -W/2:step:W/2; % Range of Rx points along y axis
N_rx = length(X_r); N_ry = length(Y_r); % Number of reception points simulated along the x and y axis
z_ref = 0.85; % Height of the receiver plane from the ground (m)
z = z_ref-H; %z=-1.65; % Height of the Rx points ("-" because coordinates system origin at the center of the ceiling)
if ( abs(z) > H )
fprintf( 'ERROR: The receiver plane is out of the room.\n' );
return
end
param_r = {A_det, n_r, FOV}; % Vector of the Rx parameters used for channel simulation
%% LOS received optical power calculation
phi = 0:10:30;
psi = (0:10:30).';
N_phi = numel(phi);
N_psi = numel(psi);
H0_LOS = zeros(N_rx,N_ry,N_t,N_phi,N_psi);
P_rec_dbm = zeros(N_rx,N_ry,N_t,N_phi,N_psi);
T = param_t{1}(1,:);
P_t = param_t{3};
for r_x = 1:N_rx
for r_y = 1:N_ry
for i_t = 1:N_t
x = X_r(r_x); y = Y_r(r_y);
R = [x,y,z];
v_tr = (R-T)./norm(R-T);
d_tr = sqrt(dot(R-T,R-T));
H0_LOS(r_x,r_y,i_t,:,:) = (m+1)*A_det/(2*pi*d_tr^2)*cosd(phi).^m.*cosd(psi);
end
end
end
P_r_LOS = P_t.*H0_LOS.*T_s.*G_Con;
P_rec_dbm = 10*log10(P_r_LOS*1000);
%% Plotting
figure
[x,y] = meshgrid(X_r,Y_r);
P_rec_dbm_extracted = P_rec_dbm(:,:,:,3,5);
size(x);
size(y);
size(P_rec_dbm_extracted);
meshc(X_r,Y_r,P_rec_dbm_extracted);
colorbar
xlabel( 'X(m)' );
ylabel( 'Y(m)' );
zlabel( 'Received power (dBm)' );
axis([-L/2 L/2 -W/2 W/2 min(min(P_rec_dbm_extracted)) max(max(P_rec_dbm_extracted))]);
figure
plot(X_r,P_rec_dbm_extracted)
xlabel( 'X(m)' );
ylabel( 'Received power (dBm)' );
  12 Comments

Sign in to comment.

Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by