Appendix A:  Model Code

 

 

plexpmapcreate – Map Creation

 

% plexpmapcreate.m - Program for creating a received power map for an antenna

%

% Example Usage:

%

% >> antenna = plexpmapcreate(antennastruct);

%

% This function will use the azimuth of the input antenna to create a received power map

% with a path loss exponent.  A new antenna structure is created with all attributes of

% the input antenna structure except for the new received power map.

%

 

function antenna = plexpmapcreate(antennastruct)

 

antenna = antennastruct;                                                            %initialize variables and create temporary maps

rpm = zeros(203,203);

rpmtemp = rpm;

rpmtemp2 = rpm;

rpmtemp3 = rpm;

d = distancemap(rpmtemp);                                                      %creates a map containing distance from origin (see below)

anglemap = anglenormalize(antennastruct);                                 %creates a map containing angle data normalized

erp = 25;                                                                                  %   to the azimuth (see below)

 

Rtemp = 0;

gain = 0;

 

wavelength = 3*10e8/850e6;

pi = 3.141;

 

for k = 1:203                                                                             %iterates through each point in map

    for l = 1:203

        Rtemp = d(k,l);

        gain = cos(pi/180*anglemap(k,l))^(.73);                             %antenna gain pattern

        if Rtemp==0

            rpmtemp(k,l)=0;

        else

            if anglemap(k,l)<90

                rpmtemp(k,l)=erp*gain-7-34*log10(Rtemp);               %link budget equation to compute received power

            else

                rpmtemp(k,l)=erp*gain*.25-7-34*log10(Rtemp);

            end

        end

    end

end

 

for k = 1:203                                                                             %iterates through each point in map

    for l = 1:203

        if anglemap(k,l)<90 & rpmtemp(k,l)>(-50)                         %sets highest value to -50 dBm for front of antenna

            rpmtemp2(k,l)=-50;

        else

            if anglemap(k,l)>90 & rpmtemp(k,l)>(-70)                     %sets highest value to -70 dBm for back of antenna

                rpmtemp2(k,l)=-70;

            else

                rpmtemp2(k,l)=rpmtemp(k,l);

            end

        end

        if rpmtemp2(k,l)<(-83)                                                      %sets lowest value to -83 dBm

            rpmtemp3(k,l)=-83;

        else

            rpmtemp3(k,l)=rpmtemp2(k,l);

        end

    end

end

 

rpm=rpmtemp3;

 

antenna.ReceivedPowerMap = rpm;

 

distancemap – Computing Distance from Antenna

 

% distancemap.m - Program for creating a map of distances from antenna

%

% Example Usage:

%

% >> dmap = distancemap(map);

%

% This function will create a map, the same size as the input map, whose values

% correspond to the distance from the antenna, located at the origin (101,101).

% Each pixel corresponds to a 10m x 10m distance.

%

 

function dmap = distancemap(map)

 

dmaptemp = map;                                                                                                 %initializes map

 

for k = 1:203

    for l = 1:203

        a = abs(10*(k-101))*abs(10*(k-101)) + abs(10*(l-101))*abs(10*(l-101));         %computes distance from origin for

        dmaptemp(k,l) = sqrt(a);                                                                                %each pixel in map

    end

end

 

dmap = dmaptemp;

 

anglenormalize – Normalizing Angles to Azimuth

 

% anglenormalize.m - Program for normalizing angles to the azimuth of an antenna

%

% Example Usage:

%

% >> angmap = anglenormalize(antenna);

%

% This function will create a map, the same size as the received power map of

% the input antenna, whose values correspond to the angle (0-180 degrees) from

% the any point to the azimuth of the input antenna.

%

 

function angmap = anglenormalize(antenna)

 

angmaptemp = antenna.ReceivedPowerMap;

angle = antenna.azimuth;                                                            %initializes variables

angletemp = 0;

angdiff = 0;

 

for k = 1:203

    for l = 1:203

        angletemp = ang(k,l);                                                         %computes angle of pixel (see below)

        angdiff = angle-angletemp;

        if angdiff > 180

            angmaptemp(k,l) = 360-angle+angletemp;

        else                                                                                  %normalizes angle to the azimuth

            if angdiff > 0

                angmaptemp(k,l) = angdiff;

            else

                if angdiff > -180

                    angmaptemp(k,l) = angletemp-angle;

                else

                    angmaptemp(k,l) = 360-angletemp+angle;

                end

            end

        end

    end

end

 

angmap = angmaptemp;

 

ang – Computing the Angle of a Pixel

 

% ang.m - Program for computing the angle of at a point

%

% Example Usage:

%

% >> angl = ang(k,l);

%

% This function will compute the angle of the pixel with respect to north.

% North is given the value of 0 degrees.  The point (101,101) is given as

% the origin.

%

 

function angl = ang(k,l)

 

pi = 3.1415;

denom = k-101;                                                              %sets denominator for tan(angl)=num/denom

num = l-101;                                                                   %sets numerator for tan(angl)=num/denom

angletemp = 0;

 

if num==0

    if denom<0

        angletemp = 180;                                                     %computes special cases at 0, 90, 180, and 270 degrees

    else

        angletemp = 0;

    end

else

    if denom==0

        if num>0

            angletemp=90;

        else

            angletemp=270;

        end

    else

        if num>0

            if denom>0

                angletemp=atan(num/denom)*180/pi;               %computes angle

            else

                angletemp=atan(num/denom)*180/pi+180;

            end

        else

            if denom<0

                angletemp=atan(num/denom)*180/pi+180;

            else

                angletemp=atan(num/denom)*180/pi+360;

            end

        end

    end

end

 

angl = angletemp;

 

 

Back to Propagation Modeling

 

References

 

Appendix B