# Location Tracking/Mathematical Theory

For the purpose of simplicity we will just assume the Free Space Path Loss (FSPL). This is the theoretical loss from the transmitter through free space against distance (see http://en.wikipedia.org/wiki/Free-space_path_loss for details). It works from the model of the antenna radiating in all directions.

## Matlab

This plots a 3d model of propogation

To run: Save as fspl.m, open and run.

```%% Plotting in 3D

% Clear workspace etc
clc;clear;
clear all;

% Cartesian Coordinates
x=[-0.5:0.01:0.5];
y=x;
[X,Y]=meshgrid(x,y);

% Constants
c = 3e8; % speed of light
f = 2400; % freq in MHz

% Calculation
fspl=20*log10(sqrt(X.^2+Y.^2))+20*log10(f)+32.45;

% Plot
mesh(X,Y,-fspl);
```

This produces:

!! Picture coming soon. You can run the code yourself to generate it though :)

## Applying the graphs to the real world

The above code plots the path loss for 500m each direction away from the source, with points every 10m, at 2.4GHz. The distance is worked out with simple pythag.

It is plotted as a negative as what you want for your link budget is

```Signal Strength (dBm) = Tx power (dBm) + gains (dB) - losses (dB)
```

FSPL is a loss (clue's in the name) so will be taken away.