# How can I calculate the H0_LOS & P_rec_dBm and draw it at every new psi value?

1 visualizzazione (ultimi 30 giorni)
Haitham AL Satai il 17 Lug 2022
Modificato: Haitham AL Satai il 19 Lug 2022
Hello, dears. Here, I am trying to calculate 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 and psi = 0:5:30, it only gave me the results for the last value of psi which is 30.
I want to calculate the received optical power and draw it at every new psi value, while phi = 0.
May I get any assistance, please?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Torsten il 17 Lug 2022
If psi becomes an array instead of a single value, the expression
(m+1)*A_det/(2*pi*d_tr^2)*cos(phi)^m*cos(psi)
also becomes an array.
H0_LOS(r_x,r_y,i_t)
is a scalar.
So you want to save an array as a scalar:
H0_LOS(r_x,r_y,i_t)= (m+1)*A_det/(2*pi*d_tr^2)*cos(phi)^m*cos(psi);
This will give an error.
You must make the array H0_LOS 4D:
H0_LOS(N_rx,N_ry,N_t,N_phi)
where N_phi is the number of elements of the array "phi".
And note that for arguments in degree instead of radians, you have to use "cosd" instead of "cos".
##### 2 CommentiMostra NessunoNascondi Nessuno
Haitham AL Satai il 17 Lug 2022
Thank you very much, dear, for your answer, but how can I translate N_phi as code because I already initialized H0_LOS with a 3D zeros matrix H0_LOS = zeros(N_rx, N_ry, N_t); above, so I want to add the fourth dimension, it does not accept it.
Torsten il 17 Lug 2022
psi = 0:5:30;
N_psi = numel(psi);
H0_LOS = zeros(N_rx,N_ry,N_t,N_psi);
P_rec_dbm = zeros(N_rx,N_ry,N_t,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));
%cos_phi = abs(dot(n_t,v_tr));
%cos_psi = abs(dot(n_r,v_tr));
phi = 0;
%psi = 0;
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
end
Since I don't know the other arrays, I don't know whether
P_r_LOS = P_t.*H0_LOS.*T_s.*G_Con;
P_rec_dBm = 10*log10(P_r_LOS*1000);
still works after this change.

Accedi per commentare.

### Categorie

Scopri di più su MATLAB in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by