Why does my for loop only output the last-time result
Show older comments
I want to calculate different received power for different receiver coordinates, but why does my loop only get the same result?
rx = 4;
ry = 8;
rz = 3;
h = 2;
% Lambertian emission order
n = 1;
ne = 1;
% detector physical area of a PD
A = 1e-4;
% FOV of a receiver
FOV = 95;
%% first transmitter calculation
TP1=[1 1 3]; % transmitter position
% Distance between transmitter and receiver
% reciver
x=linspace(1,rx,4);
y=linspace(1,ry,8);
z=linspace(1,rz,3);
for ii = 1:rx %1 to 4
for jj = 1:ry %1 to 8
RP=[x(ii) y(jj) 1]; % receiver position vector
h_a1(ii,jj)=0; % reflection from North face
DLOS = sqrt(dot(TP1-RP,TP1-RP));% distance between transmitter and receiver
cos_alphaLOS = abs(RP(3)-TP1(3))/DLOS;
cos_betaLOS = abs(TP1(3)-RP(3))/DLOS;
if abs(acosd(cos_betaLOS)) <= FOV
%receiver power
h_a1(ii,jj) = h_a1(ii,jj) + ((n+1) * A * (cos_alphaLOS ^ n) * cos_betaLOS * Ps) / 2 * pi * (DLOS ^ 2);
end
end
end

Accepted Answer
More Answers (0)
Categories
Find more on MATLAB 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!