How can I calculate the H0_LOS & P_rec_dBm and draw it at every new psi value?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Haitham AL Satai
am 17 Jul. 2022
Bearbeitet: Haitham AL Satai
am 19 Jul. 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 Kommentare
Akzeptierte Antwort
Torsten
am 17 Jul. 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 Kommentare
Torsten
am 17 Jul. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Language Fundamentals finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!