# Documentation

## Free Space Path Loss

### Support for Modeling Propagation in Free Space

Propagation environments have significant effects on the amplitude, phase, and shape of propagating space-time wavefields. In some cases, you may want to simulate a system that propagates narrowband signals through free space. If so, you can use the `phased.FreeSpace` System object™ to model the range-dependent time delay, phase shift, Doppler shift, and gain effects.

Consider this object as a point-to-point propagation channel. By setting object properties, you can customize certain characteristics of the environment and the signals propagating through it, including:

• Propagation speed and sampling rate of the signal you are propagating

• Signal carrier frequency

• Whether the object models one-way or two-way propagation

Each time you call `step` on a `phased.FreeSpace` object, you specify not only the signal to propagate, but also the location and velocity of the signal origin and destination.

You can use `fspl` to determine the free space path loss, in decibels, for a given distance and wavelength.

### Free Space Path Loss in Decibels

Assume a transmitter is located at `[1000; 250; 10]` in the global coordinate system. Assume a target is located at ```[3000; 750; 20]```. The transmitter operates at 1 GHz. Determine the free space path loss in decibels for a narrowband signal propagating to and from the target.

```[tgtrng,~] = rangeangle([3000; 750; 20],[1000; 250; 10]); % Multiply range by two for two-way propagation tgtrng = 2*tgtrng; % Determine the wavelength for 1 GHz lambda = physconst('LightSpeed')/1e9; L = fspl(tgtrng,lambda)```

The free space path loss in decibels is approximately 105 dB. You can express this value as:

`Loss = pow2db((4*pi*tgtrng/lambda)^2)`

which is a direct implementation of the equation for free space path loss.

### Propagation of a Linear FM Pulse Waveform to and from a Target

Construct a linear FM pulse waveform 50 ms in duration with a bandwidth of 100 kHz. Model the range-dependent time delay and amplitude loss incurred during two-way propagation. The pulse propagates between the transmitter located at `[1000; 250; 10]` and a target location of `[3000; 750; 20]`.

```hwav = phased.LinearFMWaveform('SweepBandwidth',1e5,... 'PulseWidth',5e-5,'OutputFormat','Pulses',... 'NumPulses',1,'SampleRate',1e6,'PRF',1e4); wf = step(hwav); hpath = phased.FreeSpace('SampleRate',1e6,... 'TwoWayPropagation',true,'OperatingFrequency',1e9); y = step(hpath,wf,[1000; 250; 10],[3000; 750; 20],... [0;0;0],[0;0;0]);```

Plot the magnitude of the transmitted and received pulse to show the amplitude loss and time delay. Scale the time axis in microseconds.

```t = unigrid(0,1/hwav.SampleRate,1/hwav.PRF,'[)'); subplot(2,1,1) plot(t.*1e6,abs(wf)); title('Magnitude of Transmitted Pulse'); xlabel('Microseconds'); ylabel('Magnitude'); subplot(2,1,2); plot(t.*1e6,abs(y)); title('Magnitude of Received Pulse'); xlabel('Microseconds'); ylabel('Magnitude');```

The delay in the received pulse is approximately 14 μs, which is exactly what you expect for a distance of 4.123 km at the speed of light.

### One-Way and Two-Way Propagation

The `TwoWayPropagation` property of the `phased.FreeSpace` object enables you to use the `step` method for one- or two-way propagation. The following example demonstrates how to use this property for a single linear FM pulse propagated to and from a target. The sensor is a single isotropic radiating antenna operating at 1 GHz located at `[1000; 250; 10]`. The target is located at `[3000; 750; 20]` and has a nonfluctuating RCS of 1 square meter.

The following code constructs the required objects and calculates the range and angle from the antenna to the target.

```hwav = phased.LinearFMWaveform('SweepBandwidth',1e5,... 'PulseWidth',5e-5,'OutputFormat','Pulses',... 'NumPulses',1,'SampleRate',1e6); hant = phased.IsotropicAntennaElement(... 'FrequencyRange',[500e6 1.5e9]); htx = phased.Transmitter('PeakPower',1e3,'Gain',20); hrad = phased.Radiator('Sensor',hant,'OperatingFrequency',1e9); hpath = phased.FreeSpace('SampleRate',1e6,... 'TwoWayPropagation',true,'OperatingFrequency',1e9); htgt = phased.RadarTarget('MeanRCS',1,'Model','Nonfluctuating'); hcol = phased.Collector('Sensor',hant,'OperatingFrequency',1e9); sensorpos = [3000; 750; 20]; tgtpos = [1000; 250; 10]; [tgtrng,tgtang] = rangeangle(sensorpos,tgtpos);```

Because the `TwoWayPropagation` property is set to `true`, you call the `step` method for the `phased.FreeSpace` object only once. The following code calls the `step` after the pulse is radiated from the antenna and before the pulse is reflected from the target.

```pulse = step(hwav); % Generate pulse pulse = step(htx,pulse); % Transmit pulse pulse = step(hrad,pulse,tgtang); % Radiate pulse % Propagate pulse to and from target pulse = step(hpath,pulse,sensorpos,tgtpos,[0;0;0],[0;0;0]); pulse = step(htgt,pulse); % Reflect pulse sig = step(hcol,pulse,tgtang); % Collect pulse```

Alternatively, if you prefer to break up the two-way propagation into two separate calls to the `step` method, you can do so by setting the `TwoWayPropagation` property to `false`.

```hpath = phased.FreeSpace('SampleRate',1e9,... 'TwoWayPropagation',false,'OperatingFrequency',1e6); pulse = step(hwav); % Generate pulse pulse = step(htx,pulse); % Transmit pulse pulse = step(hrad,pulse,tgtang); % Radiate pulse % Propagate pulse from the antenna to the target pulse = step(hpath,pulse,sensorpos,tgtpos,[0;0;0],[0;0;0]); pulse = step(htgt,pulse); % Reflect pulse % Propagate pulse from the target to the antenna pulse = step(hpath,pulse,tgtpos,sensorpos,[0;0;0],[0;0;0]); sig = step(hcol,pulse,tgtang); % Collect pulse```

### Propagation from Stationary Radar to Moving Target

This example shows how to propagate a signal in free space from a stationary radar to a moving target.

Define the signal's sample rate, propagation speed, and carrier frequency. Define the signal as a sinusoid of frequency 150 Hz.

```fs = 1000; c = 1500; fc = 300e3; N = 1024; t = (0:N-1)'/fs; x = exp(1i*2*pi*150*t);```

Assume the target is approaching the radar at 0.5 m/s, and the radar is stationary. Find the Doppler shift that corresponds to this relative speed.

```v = 0.5; dop = speed2dop(v,c/fc)```
```dop = 100```

Create a `phased.FreeSpace` object, and use it to propagate the signal from the radar to the target. Assume the radar is at (0, 0, 0) and the target is at (100, 0, 0).

```hpath = phased.FreeSpace('SampleRate',fs,... 'PropagationSpeed',c,'OperatingFrequency',fc); origin_pos = [0;0;0]; dest_pos = [100;0;0]; origin_vel = [0;0;0]; dest_vel = [-v;0;0]; y = step(hpath,x,origin_pos,dest_pos,origin_vel,dest_vel);```

Plot the spectrum of the transmitted signal. The peak at 150 Hz reflects the frequency of the signal.

```figure; window = 64; ovlp = 32; [Pxx,F] = pwelch(x,window,ovlp,N,fs); plot(F,10*log10(Pxx)); grid; xlabel('Frequency (Hz)'); ylabel('Power/Frequency (dB/Hz)'); title('Transmitted Signal')```

Plot the spectrum of the propagated signal. The peak at 250 Hz reflects the frequency of the signal plus the Doppler shift of 100 Hz.

```figure; window = 64; ovlp = 32; [Pyy,F] = pwelch(y,window,ovlp,N,fs); plot(F,10*log10(Pyy)); grid; xlabel('Frequency (Hz)'); ylabel('Power/Frequency (dB/Hz)'); title('Propagated Signal');```