Skip to main content
. 2017 Sep 6;17(9):2038. doi: 10.3390/s17092038
Algorithm 1 Recursive algorithm to calculate the impulse response.
  • 1:

    function h_func(h,tx,rx,s,sant,P,d,ki,k)

  • 2:

          if k==ki then                                              ▹ Source is TX

  • 3:

                 if ki==0 then                                        ▹ Receiver is RX

  • 4:

                        Calculate [ω, γ, drs] from (tx, rx) with (9)–(11)

  • 5:

                        Calculate signal strength Prs with (8) substituting Ps for P

  • 6:

                        Calculate discrete time trs from distance d+drs, and light velocity

  • 7:

                        if γ < FoV then

  • 8:

                              htrs=htrs+Prs

  • 9:

                        end if

  • 10:

                 else                              ▹ Received signal strength at all points from TX

  • 11:

                        for i from 1 to N do

  • 12:

                             Calculate [ω, γ, drs] from tx,i with (9)–(11) substituting rx for the i element

  • 13:

                             Calculate signal strength Prs with (8) substituting rx for the i element and Ps for P

  • 14:

                             h_func(h,tx,rx,i,tx,Prs,d+drs,ki-1,k)

  • 15:

                        end for

  • 16:

                 end if

  • 17:

          else                                              ▹ Source is not TX

  • 18:

                 if ki==0 then                                     ▹ Receiver is RX

  • 19:

                        Calculate [α, dnm, γ,θ,ϕ] from (sant,s,rx) with (17)–(20), (23) substituting n=rx, m=s and l=sant

  • 20:

                        Calculate signal strength Pnml with (14) substituting Pml for P

  • 21:

                        Calculate discrete time tnm from distance d+dnm, and light velocity

  • 22:

                        if α < FoV then

  • 23:

                             h(tnm)=h(tnm)+Pnml

  • 24:

                        end if

  • 25:

                 else                             ▹ Received signal strength at all points from TX

  • 26:

                        for i from 1 to N do

  • 27:

                             Calculate [α,dnm,γ,θ,ϕ] from sant,s,i with (17)–(20), (23) substituting n=i, m=s and l=sant

  • 28:

                             Calculate signal strength Pnml with (14) substituting Pml for P

  • 29:

                             h_func(h,tx,rx,i,s,Pnml,d+dnm,ki-1,k)

  • 30:

                        end for

  • 31:

                 end if

  • 32:

          end if

  • 33:

    end function