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

1 回表示 (過去 30 日間)
Haitham AL Satai
Haitham AL Satai 2022 年 7 月 17 日
編集済み: Haitham AL Satai 2022 年 7 月 19 日
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?

採用された回答

Torsten
Torsten 2022 年 7 月 17 日
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 件のコメント
Haitham AL Satai
Haitham AL Satai 2022 年 7 月 17 日
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
Torsten 2022 年 7 月 17 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by