title: How to consider cos(phi) & cos(psi) in my following code to calculate the received optical power for VLC LED system?
body: <p>dears. I am trying to implement Matlab's indoor visible light communication system to calculate the optical received power. And I successfully made a line of sight calculation for the power between the source LED and the receiver PD based on the following formula,</p>
  <p><a href="https://i.stack.imgur.com/SQ2ZT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SQ2ZT.png" alt="enter image description here" /></a></p>
  <p>That is in the following line code:</p>
  <pre><code>H_A1 = (m+1)*Adet.*cosphi_A1.^(m+1)./(2*pi.*D1.^2);   % Channel DC gain for source
  </code></pre>
  <p>As shown in the above picture, there is <strong>cos(phi)</strong> and <strong>cos(psi)</strong>, <em>Tf &amp; Gc</em> will be ignored. In the following code, <strong>cos(phi)</strong> and <strong>cos(psi)</strong> are ignored and considered <strong>1</strong> due to line of sight rules.</p>
  <p>What I am trying here to do is I want to consider <strong>cos(phi)</strong> and <strong>cos(psi)</strong> in the above line of code by assuming <strong>psi = 0 <strong>and</strong> phi = 0:5:30.</strong></p>
  <p>I want to add <strong>cos(phi)</strong> and <strong>cos(psi)</strong> in the following line based on the above picture</p>
  <pre><code>H_A1 = (m+1)*Adet.*cosphi_A1.^(m+1)./(2*pi.*D1.^2);   % Channel DC gain for source
  </code></pre>
  <p>And give <strong>phi=0</strong>, <strong>psi= 0</strong> to <strong>30</strong> with increasing step <strong>5</strong>.</p>
  <p>In every new value to <strong>psi</strong>, I want to calculate <strong>H_A1</strong> in order to calculate the received power <strong>P_rec</strong>.</p>
  <p>Any assistance, please?</p>
  <p>Matlab code:</p>
  <pre><code>close all;
  clear all;
  clc;
  
  %% LED/PD Parameters
  
  theta = 70;                       % Semi-angle at half power
  m = -log10(2)/log10(cosd(theta)); % Lambertian order of emission
  P_total = 20;                     % Transmitted optical power by individual LED
  Adet = 1e-4;                      % Detector physical area of a PD
  
  %% Optical elements parameters
  
  Ts = 1;                           % Gain of an optical filter; ignore if no filter is used
  index = 1.5;                      % Refractive index of a lens at a PD; ignore if no lens is used
  FOV = 60*pi/180;                  % FOV of a receiver
  G_Con = (index^2)/sin(FOV);       % Gain of an optical concentrator; ignore if no lens is used
  
  %% Room parameters
               
  lx = 5; ly = 5; lz = 3;         % Room dimensions in meter
  h = 2.15;                       % The distance between the source and receiver plane
  
  %% Mesh setup
  % 2 dimensional setup
  
  XT = 0; YT = 0;                   % The Position of the LED
  Nx = lx*10; Ny = ly*10;           % Number of grids in the receiver plane
  x = -lx/2 : lx/Nx : lx/2;
  y = -ly/2 : ly/Ny : ly/2;
  [XR, YR] = meshgrid(x,y);         % Receiver plane grid
  
  %% Computation based on LOS channel equations
  
  D1 = sqrt((XR-XT(1,1)).^2 + (YR-YT(1,1)).^2 + h^2);   % Distance vector from source
  cosphi_A1 = h./D1;                                    % Angle vector
  H_A1 = (m+1)*Adet.*cosphi_A1.^(m+1)./(2*pi.*D1.^2);   % Channel DC gain for source
  P_rec = P_total.*H_A1.*Ts.*G_Con;                     % Received power from source  
  P_rec_dB = 10*log10(P_rec); 
      
  %% Plotting
  
  meshc(x,y,P_rec_dBm);
  colorbar
  xlabel('X (m)');
  ylabel('Y (m)');
  zlabel('Received power (dBm)');
  axis([-lx/2 lx/2 -ly/2 ly/2 min(min(P_rec_dBm)) max(max(P_rec_dBm))]);
  </code></pre>