# twoRayChannel

## Description

The `twoRayChannel`

models a narrowband two-ray
propagation channel. A two-ray propagation channel is the simplest type of multipath
channel. You can use a two-ray channel to simulate propagation of signals in a
homogeneous, isotropic medium with a single reflecting boundary. This type of medium has
two propagation paths: a line-of-sight (direct) propagation path from one point to
another and a ray path reflected from the boundary. You can use this System object™ for short-range radar and mobile communications applications where the
signals propagate along straight paths and the earth is assumed to be flat. You can also
use this object for sonar and microphone applications. For acoustic applications, you
can choose the fields to be non-polarized and adjust the propagation speed to be the
speed of sound in air or water. You can use `twoRayChannel`

to model propagation from several points
simultaneously.

While the System object works for all frequencies, the attenuation models for atmospheric gases and rain are valid for electromagnetic signals in the frequency range 1–1000 GHz only. The attenuation model for fog and clouds is valid for 10–1000 GHz. Outside these frequency ranges, the System object uses the nearest valid value.

The `twoRayChannel`

System object applies range-dependent time delays to the signals, and as well as gains
or losses, phase shifts, and boundary reflection loss. The System object applies Doppler shift when either the source or destination is
moving.

Signals at the channel output can be kept *separate* or be
*combined* — controlled by the
`CombinedRaysOutput`

property. In the
*separate* option, both fields arrive at the destination
separately and are not combined. For the *combined* option, the two
signals at the source propagate separately but are coherently summed at the destination
into a single quantity. This option is convenient when the difference between the sensor
or array gains in the directions of the two paths is not significant and need not be
taken into account.

Unlike the `phased.FreeSpace`

System object, the `twoRayChannel`

System object does not support two-way propagation.

To perform two-ray channel propagation:

Create the

`twoRayChannel`

object and set its properties.Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

## Creation

### Description

creates a
two-ray propagation `channel`

= twoRayChannel`channel`

System object.

creates a two-ray propagation `channel`

= twoRayChannel(Name,Value)`channel`

System object with each specified property Name set to the specified Value. You
can specify additional name and value pair arguments in any order as
(Name1,Value1,...,NameN,ValueN).

## Properties

Unless otherwise indicated, properties are *nontunable*, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
`release`

function unlocks them.

If a property is *tunable*, you can change its value at
any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

`PropagationSpeed`

— Signal propagation speed

`physconst('LightSpeed')`

(default) | positive scalar

Signal propagation speed, specified as a positive scalar. Units are in meters per second. The
default propagation speed is the value returned by
`physconst('LightSpeed')`

. See `physconst`

for more information.

**Example: **`3e8`

**Data Types: **`double`

`OperatingFrequency`

— Operating frequency

`300e6`

(default) | positive scalar

Operating frequency, specified as a positive scalar. Units are in Hz.

**Example: **`1e9`

**Data Types: **`double`

`SpecifyAtmosphere`

— Enable atmospheric attenuation model

`false`

(default) | `true`

Option to enable the atmospheric attenuation model, specified
as a `false`

or `true`

. Set this
property to `true`

to add signal attenuation caused
by atmospheric gases, rain, fog, or clouds. Set this property to `false`

to
ignore atmospheric effects in propagation.

Setting `SpecifyAtmosphere`

to `true`

,
enables the `Temperature`

, `DryAirPressure`

, `WaterVapourDensity`

, `LiquidWaterDensity`

,
and `RainRate`

properties.

**Data Types: **`logical`

`Temperature`

— Ambient temperature

`15`

(default) | real-valued scalar

Ambient temperature, specified as a real-valued scalar. Units are in degrees Celsius.

**Example: **`20.0`

#### Dependencies

To enable this property, set `SpecifyAtmosphere`

to `true`

.

**Data Types: **`double`

`DryAirPressure`

— Atmospheric dry air pressure

`101.325e3`

(default) | positive real-valued scalar

Atmospheric dry air pressure, specified as a positive real-valued scalar. Units are in pascals (Pa). The default value of this property corresponds to one standard atmosphere.

**Example: **`101.0e3`

#### Dependencies

To enable this property, set `SpecifyAtmosphere`

to `true`

.

**Data Types: **`double`

`WaterVapourDensity`

— Atmospheric water vapor density

`7.5`

(default) | positive real-valued scalar

Atmospheric water vapor density, specified as a positive real-valued
scalar. Units are in g/m^{3}.

**Example: **`7.4`

#### Dependencies

To enable this property, set `SpecifyAtmosphere`

to `true`

.

**Data Types: **`double`

`LiquidWaterDensity`

— Liquid water density

`0.0`

(default) | nonnegative real-valued scalar

Liquid water density of fog or clouds, specified as a nonnegative
real-valued scalar. Units are in g/m^{3}.
Typical values for liquid water density are 0.05 for medium fog and
0.5 for thick fog.

**Example: **`0.1`

#### Dependencies

To enable this property, set `SpecifyAtmosphere`

to `true`

.

**Data Types: **`double`

`RainRate`

— Rainfall rate

`0.0`

(default) | nonnegative scalar

Rainfall rate, specified as a nonnegative scalar. Units are in mm/hr.

**Example: **`10.0`

#### Dependencies

To enable this property, set `SpecifyAtmosphere`

to `true`

.

**Data Types: **`double`

`SampleRate`

— Sample rate of signal

`1e6`

(default) | positive scalar

Sample rate of signal, specified as a positive scalar. Units are in Hz. The System object uses this quantity to calculate the propagation delay in units of samples.

**Example: **`1e6`

**Data Types: **`double`

`EnablePolarization`

— Enable polarized fields

`false`

(default) | `true`

Option to enable polarized fields, specified as `false`

or
`true`

. Set this property to `true`

to enable
polarization. Set this property to `false`

to ignore
polarization.

**Data Types: **`logical`

`GroundReflectionCoefficient`

— Ground reflection coefficient

`-1`

(default) | complex-valued scalar | complex-valued 1-by-*N* row vector

Ground reflection coefficient for the field at the reflection
point, specified as a complex-valued scalar or a complex-valued 1-by-*N* row
vector. Each coefficient has an absolute value less than or equal
to one. The quantity *N* is the number of two-ray
channels. Units are dimensionless. Use this property to model nonpolarized
signals. To model polarized signals, use the `GroundRelativePermittivity`

property.

**Example: **`-0.5`

#### Dependencies

To enable this property, set `EnablePolarization`

to `false`

.

**Data Types: **`double`

**Complex Number Support: **Yes

`GroundRelativePermittivity`

— Ground relative permittivity

`15`

(default) | positive real-valued scalar | real-valued 1-by-*N*row vector of positive
values

Relative permittivity of the ground at the reflection point,
specified as a positive real-valued scalar or a 1-by-*N* real-valued
row vector of positive values. The dimension *N* is
the number of two-ray channels. Permittivity units are dimensionless.
Relative permittivity is defined as the ratio of actual ground permittivity
to the permittivity of free space. This property applies when you
set the `EnablePolarization`

property to `true`

.
Use this property to model polarized signals. To model nonpolarized
signals, use the `GroundReflectionCoefficient`

property.

**Example: **`5`

#### Dependencies

To enable this property, set `EnablePolarization`

to `true`

.

**Data Types: **`double`

`CombinedRaysOutput`

— Option to combine two rays at output

`true`

(default) | `false`

Option to combine the two rays at channel output, specified
as `true`

or `false`

. When this
property is `true`

, the object coherently adds the
line-of-sight propagated signal and the reflected path signal when
forming the output signal. Use this mode when you do not need to include
the directional gain of an antenna or array in your simulation.

**Data Types: **`logical`

`MaximumDistanceSource`

— Source of maximum one-way propagation distance

`'Auto'`

(default) | `'Property'`

Source of maximum one-way propagation distance, specified as `'Auto'`

or `'Property'`

.
The maximum one-way propagation distance is used to allocate sufficient
memory for signal delay computation. When you set this property to `'Auto'`

,
the System object automatically allocates memory. When you set
this property to `'Property'`

, you specify the maximum
one-way propagation distance using the value of the `MaximumDistance`

property.

**Data Types: **`char`

`MaximumDistance`

— Maximum one-way propagation distance

`10000`

(default) | positive real-valued scalar

Maximum one-way propagation distance, specified as a positive real-valued scalar. Units are in meters. Any signal that propagates more than the maximum one-way distance is ignored. The maximum distance must be greater than or equal to the largest position-to-position distance.

**Example: **`5000`

#### Dependencies

To enable this property, set the `MaximumDistanceSource`

property
to `'Property'`

.

**Data Types: **`double`

`MaximumNumInputSamplesSource`

— Source of maximum number of samples

`'Auto'`

(default) | `'Property'`

The source of the maximum number of samples of the input signal, specified as
`'Auto'`

or `'Property'`

. When you set this
property to `'Auto'`

, the propagation model automatically allocates
enough memory to buffer the input signal. When you set this property to
`'Property'`

, you specify the maximum number of samples in the
input signal using the `MaximumNumInputSamples`

property. Any input
signal longer than that value is truncated.

To use this object with variable-size signals in a MATLAB^{®} Function Block in Simulink^{®}, set the `MaximumNumInputSamplesSource`

property to
`'Property'`

and set a value for the
`MaximumNumInputSamples`

property.

**Example: **`'Property'`

#### Dependencies

To enable this property, set `MaximumDistanceSource`

to
`'Property'`

.

**Data Types: **`char`

`MaximumNumInputSamples`

— Maximum number of input signal samples

`100`

(default) | positive integer

Maximum number of input signal samples, specified as a positive integer. The size of the input signal is the number of rows in the input matrix. Any input signal longer than this number is truncated. To process signals completely, ensure that this property value is greater than any maximum input signal length.

The waveform-generating System objects determine the maximum signal size:

For any waveform, if the waveform

`OutputFormat`

property is set to`'Samples'`

, the maximum signal length is the value specified in the`NumSamples`

property.For pulse waveforms, if the

`OutputFormat`

is set to`'Pulses'`

, the signal length is the product of the smallest pulse repetition frequency, the number of pulses, and the sample rate.For continuous waveforms, if the

`OutputFormat`

is set to`'Sweeps'`

, the signal length is the product of the sweep time, the number of sweeps, and the sample rate.

**Example: **`2048`

#### Dependencies

To enable this property, set `MaximumNumInputSamplesSource`

to `'Property'`

.

**Data Types: **`double`

## Usage

### Description

returns the resulting signal, `prop_sig`

= channel(`sig`

,`origin_pos`

,`dest_pos`

,`origin_vel`

,`dest_vel`

)`prop_sig`

, when a narrowband
signal, `sig`

, propagates through a two-ray channel from the
`origin_pos`

position to the
`dest_pos`

position. Either the
`origin_pos`

or `dest_pos`

arguments
can have multiple points but you cannot specify both as having multiple points.
The velocity of the signal origin is specified in
`origin_vel`

and the velocity of the signal destination
is specified in `dest_vel`

. The dimensions of
`origin_vel`

and `dest_vel`

must agree
with the dimensions of `origin_pos`

and
`dest_pos`

, respectively.

Electromagnetic fields propagated through a two-ray channel can be polarized
or nonpolarized. For, nonpolarized fields, such as an acoustic field, the
propagating signal field, `sig`

, is a vector or matrix. When
the fields are polarized, `sig`

is an array of structures.
Every structure element represents an electric field vector in Cartesian
form.

In the two-ray environment, there are two signal paths connecting every signal
origin and destination pair. For *N* signal origins (or
*N* signal destinations), there are *2N*
number of paths. The signals for each origin-destination pair do not have to be
related. The signals along the two paths for any single source-destination pair
can also differ due to phase or amplitude differences.

You can keep the two signals at the destination *separate*
or *combined* — controlled by the
`CombinedRaysOutput`

property.
*Combined* means that the signals at the source propagate
separately along the two paths but are coherently summed at the destination into
a single quantity. To use the *separate* option, set
`CombinedRaysOutput`

to `false`

. To use
the *combined* option, set
`CombinedRaysOutput`

to `true`

. This
option is convenient when the difference between the sensor or array gains in
the directions of the two paths is not significant and need not be taken into
account.

### Input Arguments

`sig`

— Narrowband signal

*M*-by-*N* complex-valued
matrix | *M*-by-*2N* complex-valued
matrix | 1-by-*N*
`struct`

array containing complex-valued fields | 1-by-*2N*
`struct`

array containing complex-valued fields

Narrowband nonpolarized scalar signal, specified as an

*M*-by-*N*complex-valued matrix. Each column contains a common signal propagated along both the line-of-sight path and the reflected path. You can use this form when both path signals are the same.*M*-by-*2N*complex-valued matrix. Each adjacent pair of columns represents a different channel. Within each pair, the first column represents the signal propagated along the line-of-sight path and the second column represents the signal propagated along the reflected path.

Narrowband polarized signal, specified as a

1-by-

*N*`struct`

array containing complex-valued fields. Each`struct`

contains a common polarized signal propagated along both the line-of-sight path and the reflected path. Each structure element contains an*M*-by-1 column vector of electromagnetic field components`(sig.X,sig.Y,sig.Z)`

. You can use this form when both path signals are the same.1-by-

*2N*`struct`

array containing complex-valued fields. Each adjacent pair of array columns represents a different channel. Within each pair, the first column represents the signal along the line-of-sight path and the second column represents the signal along the reflected path. Each structure element contains an*M*-by-1 column vector of electromagnetic field components`(sig.X,sig.Y,sig.Z)`

.

For nonpolarized fields, the quantity *M* is the
number of samples of the signal and *N* is the number
of two-ray channels. Each channel corresponds to a source-destination
pair.

The size of the first dimension of the input matrix can vary to simulate a changing signal length. A size change can occur, for example, in the case of a pulse waveform with variable pulse repetition frequency.

For polarized fields, the `struct`

element contains
three *M*-by-1 complex-valued column vectors,
`sig.X`

, `sig.Y`

, and
`sig.Z`

. These vectors represent the
*x*, *y*, and *z*
Cartesian components of the polarized signal.

The size of the first dimension of the matrix fields within
the `struct`

can vary to simulate a changing signal
length such as a pulse waveform with variable pulse repetition frequency.

**Example: **`[1,1;j,1;0.5,0]`

**Data Types: **`double`

**Complex Number Support: **Yes

`origin_pos`

— Origin of the signal or signals

3-by-1 real-valued column vector | 3-by-*N* real-valued matrix

Origin of the signal or signals, specified as a 3-by-1 real-valued
column vector or 3-by-*N* real-valued matrix. The
quantity *N* is the number of two-ray channels. If
`origin_pos`

is a column vector, it takes the
form `[x;y;z]`

. If `origin_pos`

is a
matrix, each column specifies a different signal origin and has the form
`[x;y;z]`

. Position units are meters.

`origin_pos`

and `dest_pos`

cannot both be specified as matrices — at least one must be a
3-by-1 column vector.

**Example: **`[1000;100;500]`

**Data Types: **`double`

`dest_pos`

— Destination position of the signal or signals

3-by-1 real-valued column vector | 3-by-*N* real-valued matrix

Destination position of the signal or signals, specified as a 3-by-1
real-valued column vector or 3-by-*N* real-valued
matrix. The quantity *N* is the number of two-ray
channels propagating from or to *N* signal origins. If
`dest_pos`

is a 3-by-1 column vector, it takes
the form `[x;y;z]`

. If `dest_pos`

is
a matrix, each column specifies a different signal destination and takes
the form `[x;y;z]`

Position units are in meters.

You cannot specify `origin_pos`

and
`dest_pos`

as matrices. At least one must be a
3-by-1 column vector.

**Example: **`[0;0;0]`

**Data Types: **`double`

`origin_vel`

— Velocity of signal origin

3-by-1 real-valued column vector | 3-by-*N* real-valued matrix

Velocity of signal origin, specified as a 3-by-1 real-valued column
vector or 3-by-*N* real-valued matrix. The dimensions
of `origin_vel`

must match the dimensions of
`origin_pos`

. If `origin_vel`

is a column vector, it takes the form `[Vx;Vy;Vz]`

. If
`origin_vel`

is a 3-by-*N*
matrix, each column specifies a different origin velocity and has the
form `[Vx;Vy;Vz]`

. Velocity units are in meters per
second.

**Example: **`[10;0;5]`

**Data Types: **`double`

`dest_vel`

— Velocity of signal destinations

3-by-1 real-valued column vector | 3-by-*N* real-valued matrix

Velocity of signal destinations, specified as a 3-by-1 real-valued
column vector or 3–by-*N* real-valued matrix. The
dimensions of `dest_vel`

must match the dimensions of
`dest_pos`

. If `dest_vel`

is a
column vector, it takes the form `[Vx;Vy;Vz]`

. If
`dest_vel`

is a 3-by-*N* matrix,
each column specifies a different destination velocity and has the form
`[Vx;Vy;Vz]`

Velocity units are in meters per
second.

**Example: **`[0;0;0]`

**Data Types: **`double`

### Output Arguments

`prop_sig`

— Propagated signal

*M*-by-*N* complex-valued
matrix | *M*-by-*2N* complex-valued
matrix | 1-by-*N*
`struct`

array containing complex-valued fields | 1-by-*2N*
`struct`

array containing complex-valued fields

Narrowband nonpolarized scalar signal, returned as an:

*M*-by-*N*complex-valued matrix. To return this format, set the`CombinedRaysOutput`

property to`true`

. Each matrix column contains the coherently combined signals from the line-of-sight path and the reflected path.*M*-by-*2N*complex-valued matrix. To return this format set the`CombinedRaysOutput`

property to`false`

. Alternate columns of the matrix contain the signals from the line-of-sight path and the reflected path.

Narrowband polarized scalar signal, returned as:

1-by-

*N*`struct`

array containing complex-valued fields. To return this format, set the`CombinedRaysOutput`

property to`true`

. Each column of the array contains the coherently combined signals from the line-of-sight path and the reflected path. Each structure element contains the electromagnetic field vector`(prop_sig.X,prop_sig.Y,prop_sig.Z)`

.1-by-

*2N*`struct`

array containing complex-valued fields. To return this format, set the`CombinedRaysOutput`

property to`false`

. Alternate columns contains the signals from the line-of-sight path and the reflected path. Each structure element contains the electromagnetic field vector`(prop_sig.X,prop_sig.Y,prop_sig.Z)`

.

The output `prop_sig`

contains signal samples
arriving at the signal destination within the current input time frame.
Whenever it takes longer than the current time frame for the signal to
propagate from the origin to the destination, the output may not contain
all contributions from the input of the current time frame. The
remaining output will appear in the next call to the object.

## Object Functions

To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named `obj`

, use
this syntax:

release(obj)

## Examples

### Scalar Field Propagating in Two-Ray Channel

This example illustrates the two-ray propagation of a signal, showing how the signals from the line-of-sight and reflected path arrive at the receiver at different times.

**Create and Plot Propagating Signal**

Create a nonpolarized electromagnetic field consisting of two rectangular waveform pulses at a carrier frequency of 100 MHz. Assume the pulse width is 10 ms and the sampling rate is 1 MHz. The bandwidth of the pulse is 0.1 MHz. Assume a 50% duty cycle in so that the pulse width is one-half the pulse repetition interval. Create a two-pulse wave train. Set the `GroundReflectionCoefficient`

to 0.9 to model strong ground reflectivity. Propagate the field from a stationary source to a stationary receiver. The vertical separation of the source and receiver is approximately 10 km.

c = physconst('LightSpeed'); fs = 1e6; pw = 10e-6; pri = 2*pw; PRF = 1/pri; fc = 100e6; lambda = c/fc; waveform = phased.RectangularWaveform('SampleRate',fs,'PulseWidth',pw,... 'PRF',PRF,'OutputFormat','Pulses','NumPulses',2); wav = waveform(); n = size(wav,1); figure; plot((0:(n-1)),real(wav),'b.-'); xlabel('Time (samples)') ylabel('Waveform magnitude')

**Specify the Location of Source and Receiver**

Place the source and receiver about 1000 meters apart horizontally and approximately 10 km apart vertically.

pos1 = [1000;0;10000]; pos2 = [0;100;100]; vel1 = [0;0;0]; vel2 = [0;0;0];

Compute the predicted signal delays in units of samples.

`[rng,ang] = rangeangle(pos2,pos1,'two-ray');`

**Create a Two-Ray Channel System Object™**

Create a two-ray propagation channel System object™ and propagate the signal along both the line-of-sight and reflected ray paths.

channel = twoRayChannel('SampleRate',fs,... 'GroundReflectionCoefficient',.9,'OperatingFrequency',fc,... 'CombinedRaysOutput',false); prop_signal = channel([wav,wav],pos1,pos2,vel1,vel2);

**Plot the Propagated Signals**

Plot the signal propagated along the line-of-sight.

Then, overlay a plot of the signal propagated along the reflected path.

Finally, overlay a plot of the coherent sum of the two signals.

n = size(prop_signal,1); delay = 0:(n-1); plot(delay,abs(prop_signal(:,1)),'g') hold on plot(delay,abs(prop_signal(:,2)),'r') plot(delay,abs(prop_signal(:,1) + prop_signal(:,2)),'b') hold off legend('Line-of-sight','Reflected','Combined','Location','NorthWest') xlabel('Delay (samples)') ylabel('Signal Magnitude')

The plot shows that the delay of the reflected path signal agrees with the predicted delay. The magnitude of the coherently combined signal is less than either of the propagated signals indicating that there is some interference between the two signals.

### Polarized Field Propagation in Two-Ray Channel

Create a polarized electromagnetic field consisting of linear FM waveform pulses. Propagate the field from a stationary source with a crossed-dipole antenna element to a stationary receiver approximately 10 km away. The transmitting antenna is 100 meters above the ground. The receiving antenna is 150 m above the ground. The receiving antenna is also a crossed-dipole. Plot the received signal.

**Set Radar Waveform Parameters**

Assume the pulse width is $$10\mu s$$ and the sampling rate is 10 MHz. The bandwidth of the pulse is 1 MHz. Assume a 50% duty cycle in which the pulse width is one-half the pulse repetition interval. Create a two-pulse wave train. Assume a carrier frequency of 100 MHz.

```
c = physconst('LightSpeed');
fs = 10e6;
pw = 10e-6;
pri = 2*pw;
PRF = 1/pri;
fc = 100e6;
bw = 1e6;
lambda = c/fc;
```

**Set Up Required System Objects**

Use a `GroundRelativePermittivity`

of 10.

waveform = phased.LinearFMWaveform('SampleRate',fs,'PulseWidth',pw,... 'PRF',PRF,'OutputFormat','Pulses','NumPulses',2,'SweepBandwidth',bw,... 'SweepDirection','Up','Envelope','Rectangular','SweepInterval',... 'Positive'); antenna = phased.CrossedDipoleAntennaElement(... 'FrequencyRange',[50,200]*1e6); radiator = phased.Radiator('Sensor',antenna,'OperatingFrequency',fc,... 'Polarization','Combined'); channel = twoRayChannel('SampleRate',fs,... 'OperatingFrequency',fc,'CombinedRaysOutput',false,... 'EnablePolarization',true,'GroundRelativePermittivity',10); collector = phased.Collector('Sensor',antenna,'OperatingFrequency',fc,... 'Polarization','Combined');

**Set Up Scene Geometry**

Specify transmitter and receiver positions, velocities, and orientations. Place the source and receiver about 1000 m apart horizontally and approximately 50 m apart vertically.

posTx = [0;100;100]; posRx = [1000;0;150]; velTx = [0;0;0]; velRx = [0;0;0]; laxRx = rotz(180); laxTx = rotx(1)*eye(3);

**Create and Radiate Signals from Transmitter**

Compute the transmission angles for the two rays traveling toward the receiver. These angles are defined with respect to the transmitter local coordinate system. The `phased.Radiator`

System object™ uses these angles to apply separate antenna gains to the two signals.

```
[rng,angsTx] = rangeangle(posRx,posTx,laxTx,'two-ray');
wav = waveform();
```

Plot the transmitted Waveform

n = size(wav,1); plot((0:(n-1))/fs*1000000,real(wav)) xlabel('Time ({\mu}sec)') ylabel('Waveform')

sig = radiator(wav,angsTx,laxTx);

Propagate signals to receiver via two-ray channel

prop_sig = channel(sig,posTx,posRx,velTx,velRx);

**Receive Propagated Signal**

Compute the reception angles for the two rays arriving at the receiver. These angles are defined with respect to the receiver local coordinate system. The `phased.Collector`

System object™ uses these angles to apply separate antenna gains to the two signals.

`[~,angsRx] = rangeangle(posTx,posRx,laxRx,'two-ray');`

Collect and combine received rays.

y = collector(prop_sig,angsRx,laxRx);

**Plot received waveform**

plot((0:(n-1))/fs*1000000,real(y)) xlabel('Time ({\mu}sec)') ylabel('Received Waveform')

### Compare Two-Ray with Free Space Propagation

Propagate a signal in a two-ray channel environment from a radar at (0,0,10) meters to a target at (300,200,30) meters. Assume that the radar and target are stationary and that the transmitting antenna has a cosine pattern. Compare the combined signals from the two paths with the single signal resulting from free space propagation. Set the `CombinedRaysOutput`

to `true`

to produce a combined propagated signal.

**Create a Rectangular Waveform**

Set the sample rate to 2 MHz.

```
fs = 2e6;
waveform = phased.RectangularWaveform('SampleRate',fs);
wavfrm = waveform();
```

**Create the Transmitting Antenna and Radiator**

Set up a `phased.Radiator`

System object™ to transmit from a cosine antenna

```
antenna = phased.CosineAntennaElement;
radiator = phased.Radiator('Sensor',antenna);
```

**Specify Transmitter and Target Coordinates**

posTx = [0;0;10]; posTgt = [300;200;30]; velTx = [0;0;0]; velTgt = [0;0;0];

**Free Space Propagation**

Compute the transmitting direction toward the target for the free-space model. Then, radiate the signal.

[~,angFS] = rangeangle(posTgt,posTx); wavTx = radiator(wavfrm,angFS);

Propagate the signal to the target.

```
fschannel = phased.FreeSpace('SampleRate',waveform.SampleRate);
yfs = fschannel(wavTx,posTx,posTgt,velTx,velTgt);
release(radiator);
```

**Two-Ray Propagation**

Compute the two transmit angles toward the target for line-of-sight (LOS) path and reflected paths. Compute the transmitting directions toward the target for the two rays. Then, radiate the signals.

```
[~,angTwoRay] = rangeangle(posTgt,posTx,'two-ray');
wavTwoRay = radiator(wavfrm,angTwoRay);
```

Propagate the signals to the target.

channel = twoRayChannel('SampleRate',waveform.SampleRate,... 'CombinedRaysOutput',true); y2ray = channel(wavTwoRay,posTx,posTgt,velTx,velTgt);

**Plot the Propagated Signals**

Plot the combined signal against the free-space signal

plot(abs([y2ray yfs])) legend('Two-ray','Free space') xlabel('Samples') ylabel('Signal Magnitude')

### Two-Ray Propagation of LFM Waveform

Propagate a linear FM signal in a two-ray channel. The signal propagates from a transmitter located at `(1000,10,10)`

meters in the global coordinate system to a receiver at `(10000,200,30)`

meters. Assume that the transmitter and the receiver are stationary and that they both have cosine antenna patterns. Plot the received signal.

Set up the radar scenario. First, create the required System objects.

waveform = phased.LinearFMWaveform('SampleRate',1000000,... 'OutputFormat','Pulses','NumPulses',2); fs = waveform.SampleRate; antenna = phased.CosineAntennaElement; radiator = phased.Radiator('Sensor',antenna); collector = phased.Collector('Sensor',antenna); channel = twoRayChannel('SampleRate',fs,... 'CombinedRaysOutput',false,'GroundReflectionCoefficient',0.95);

Set up the scene geometry. Specify transmitter and receiver positions and velocities. The transmitter and receiver are stationary.

posTx = [1000;10;10]; posRx = [10000;200;30]; velTx = [0;0;0]; velRx = [0;0;0];

Specify the transmitting and receiving radar antenna orientations with respect to the global coordinates. The transmitting antenna points along the *+x* direction and the receiving antenna points near but not directly in the *-x* direction.

laxTx = eye(3); laxRx = rotx(5)*rotz(170);

Compute the transmission angles which are the angles that the two rays traveling toward the receiver leave the transmitter. The phased.Radiator System object™ uses these angles to apply separate antenna gains to the two signals. Because the antenna gains depend on path direction, you must transmit and receive the two rays separately.

`[~,angTx] = rangeangle(posRx,posTx,laxTx,'two-ray');`

Create and radiate signals from transmitter along the transmission directions.

wavfrm = waveform(); wavtrans = radiator(wavfrm,angTx);

Propagate signals to receiver via two-ray channel.

wavrcv = channel(wavtrans,posTx,posRx,velTx,velRx);

Collect signals at the receiver. Compute the angle at which the two rays traveling from the transmitter arrive at the receiver. The `phased.Collector`

System object™ uses these angles to apply separate antenna gains to the two signals.

`[~,angRcv] = rangeangle(posTx,posRx,laxRx,'two-ray');`

Collect and combine the two received rays.

yR = collector(wavrcv,angRcv);

Plot the received signals.

dt = 1/fs; n = size(yR,1); plot((0:(n-1))*dt*1000000,real(yR)) xlabel('Time ({\mu}sec)') ylabel('Signal Magnitude')

### Two-Ray Propagation of LFM Waveform with Atmospheric Losses

Propagate a 100 Mhz linear FM signal into a two-ray channel. Assume there is signal loss caused by atmospheric gases and rain. The signal propagates from a transmitter located at `(0,0,0)`

meters in the global coordinate system to a receiver at `(10000,200,30)`

meters. Assume that the transmitter and the receiver are stationary and that they both have cosine antenna patterns. Plot the received signal. Set the dry air pressure to 102.5 Pa and the rain rate to 5 mm/hr.

**Set Up Radar Scenario**

waveform = phased.LinearFMWaveform('SampleRate',1e6,... 'OutputFormat','Pulses','NumPulses',2); antenna = phased.CosineAntennaElement; radiator = phased.Radiator('Sensor',antenna); collector = phased.Collector('Sensor',antenna); channel = twoRayChannel('SampleRate',waveform.SampleRate,... 'CombinedRaysOutput',false,'GroundReflectionCoefficient',0.95,... 'SpecifyAtmosphere',true,'Temperature',20,... 'DryAirPressure',102.5,'RainRate',5.0);

Set up the scene geometry giving. the transmitter and receiver positions and velocities. The transmitter and receiver are stationary.

posTx = [0;0;0]; posRx = [10000;200;30]; velTx = [0;0;0]; velRx = [0;0;0];

Specify the transmitting and receiving radar antenna orientations with respect to the global coordinates. The transmitting antenna points along the *+x*-direction and the receiving antenna points close to the –*x*-direction.

laxTx = eye(3); laxRx = rotx(5)*rotz(170);

Compute the transmission angles which are the angles that the two rays traveling toward the receiver leave the transmitter. The `phased.Radiator`

System object™ uses these angles to apply separate antenna gains to the two signals. Because the antenna gains depend on path direction, you must transmit and receive the two rays separately.

`[~,angTx] = rangeangle(posRx,posTx,laxTx,'two-ray');`

**Create and Radiate Signals from Transmitter**

Radiate the signals along the transmission directions.

wavfrm = waveform(); wavtrans = radiator(wavfrm,angTx);

Propagate signals to receiver via two-ray channel.

wavrcv = channel(wavtrans,posTx,posRx,velTx,velRx);

**Collect Signal at Receiver**

Compute the angle at which the two rays traveling from the transmitter arrive at the receiver. The `phased.Collector`

System object™ uses these angles to apply separate antenna gains to the two signals.

`[~,angRcv] = rangeangle(posTx,posRx,laxRx,'two-ray');`

Collect and combine the two received rays.

yR = collector(wavrcv,angRcv);

**Plot Received Signal**

dt = 1/waveform.SampleRate; n = size(yR,1); plot((0:(n-1))*dt*1000000,real(yR)) xlabel('Time ({\mu}sec)') ylabel('Signal Magnitude')

## More About

### Two-Ray Propagation Paths

A two-ray propagation channel is the next step up in complexity from a
free-space channel and is the simplest case of a multipath propagation environment. The
free-space channel models a straight-line *line-of-sight * path from
point 1 to point 2. In a two-ray channel, the medium is specified as a homogeneous,
isotropic medium with a reflecting planar boundary. The boundary is always set at *z
= 0*. There are at most two rays propagating from point 1 to point 2. The first
ray path propagates along the same line-of-sight path as in the free-space channel. The line-of-sight path is often called the *direct
path*. The second ray reflects off the boundary before propagating to point 2.
According to the Law of Reflection , the angle of reflection equals the angle of incidence.
In short-range simulations such as cellular communications systems and automotive radars,
you can assume that the reflecting surface, the ground or ocean surface, is flat.

The `twoRayChannel`

and `widebandTwoRayChannel`

System objects model propagation time delay, phase
shift, Doppler shift, and loss effects for both paths. For the reflected path, loss effects
include reflection loss at the boundary.

The figure illustrates two propagation paths. From the source
position, *s _{s}*, and the receiver
position,

*s*, you can compute the arrival angles of both paths,

_{r}*θ′*and

_{los}*θ′*. The arrival angles are the elevation and azimuth angles of the arriving radiation with respect to a local coordinate system. In this case, the local coordinate system coincides with the global coordinate system. You can also compute the transmitting angles,

_{rp}*θ*and

_{los}*θ*. In the global coordinates, the angle of reflection at the boundary is the same as the angles

_{rp}*θ*and

_{rp}*θ′*. The reflection angle is important to know when you use angle-dependent reflection-loss data. You can determine the reflection angle by using the

_{rp}`rangeangle`

function and
setting the reference axes to the global coordinate system. The total
path length for the line-of-sight path is shown in the figure by *R*which is equal to the geometric distance between source and receiver. The total path length for the reflected path is

_{los}*R*. The quantity

_{rp}= R_{1}+ R_{2}*L*is the ground range between source and receiver.

You can easily derive exact formulas for path lengths and angles in terms of the ground range and object heights in the global coordinate system.

$$\begin{array}{l}\overrightarrow{R}={\overrightarrow{x}}_{s}-{\overrightarrow{x}}_{r}\\ {R}_{los}=\left|\overrightarrow{R}\right|=\sqrt{{\left({z}_{r}-{z}_{s}\right)}^{2}+{L}^{2}}\\ {R}_{1}=\frac{{z}_{r}}{{z}_{r}+{z}_{z}}\sqrt{{\left({z}_{r}+{z}_{s}\right)}^{2}+{L}^{2}}\\ {R}_{2}=\frac{{z}_{s}}{{z}_{s}+{z}_{r}}\sqrt{{\left({z}_{r}+{z}_{s}\right)}^{2}+{L}^{2}}\\ {R}_{rp}={R}_{1}+{R}_{2}=\sqrt{{\left({z}_{r}+{z}_{s}\right)}^{2}+{L}^{2}}\\ \mathrm{tan}{\theta}_{los}=\frac{\left({z}_{s}-{z}_{r}\right)}{L}\\ \mathrm{tan}{\theta}_{rp}=-\frac{\left({z}_{s}+{z}_{r}\right)}{L}\\ {{\theta}^{\prime}}_{los}=-{\theta}_{los}\\ {{\theta}^{\prime}}_{rp}={\theta}_{rp}\end{array}$$

### Two-Ray Attenuation

Attenuation or path loss in the two-ray channel is the product
of five components, *L = L _{tworay} L_{G} L_{g} L_{c} L_{r}*,
where

*L*is the two-ray geometric path attenuation_{tworay}*L*is the ground reflection attenuation_{G}*L*is the atmospheric path attenuation_{g}*L*is the fog and cloud path attenuation_{c}*L*is the rain path attenuation_{r}

Each component is in magnitude units, not in dB.

### Ground Reflection and Propagation Loss

Losses occurs when a signal is reflected from a boundary. You
can obtain a simple model of ground reflection loss by representing
the electromagnetic field as a scalar field. This approach also works
for acoustic and sonar systems. Let *E* be a scalar
free-space electromagnetic field having amplitude *E _{0}* at
a reference distance

*R*from a transmitter (for example, one meter). The propagating free-space field at distance

_{0}*R*from the transmitter is

_{los}$${E}_{los}={E}_{0}\left(\frac{{R}_{0}}{{R}_{los}}\right){e}^{i\omega \left(t-{R}_{los}/c\right)}$$

for the line-of-sight
path. You can express the ground-reflected *E*-field
as

$${E}_{rp}={L}_{G}{E}_{0}\left(\frac{{R}_{0}}{{R}_{rp}}\right){e}^{i\omega \left(t-{R}_{rp}/c\right)}$$

where *R _{rp}* is
the reflected path distance. The quantity

*L*represents the loss due to reflection at the ground plane. To specify

_{G}*L*, use the

_{G}`GroundReflectionCoefficient`

property.
In general, *L*depends on the incidence angle of the field. If you have empirical information about the angular dependence of

_{G}*L*, you can use

_{G}`rangeangle`

to compute
the incidence angle of the reflected path. The total field at the
destination is the sum of the line-of-sight and reflected-path fields.For electromagnetic waves, a more complicated but more realistic
model uses a vector representation of the polarized field. You can
decompose the incident electric field into two components. One component, *E _{p}*,
is parallel to the plane of incidence. The other component,

*E*, is perpendicular to the plane of incidence. The ground reflection coefficients for these components differ and can be written in terms of the ground permittivity and incidence angle.

_{s}$$\begin{array}{l}{G}_{p}=\frac{{Z}_{1}\mathrm{cos}{\theta}_{1}-{Z}_{2}\mathrm{cos}{\theta}_{2}}{{Z}_{1}\mathrm{cos}{\theta}_{1}+{Z}_{2}\mathrm{cos}{\theta}_{2}}=\frac{\mathrm{cos}{\theta}_{1}-\frac{{Z}_{2}}{{Z}_{1}}\mathrm{cos}{\theta}_{2}}{\mathrm{cos}{\theta}_{1}+\frac{{Z}_{2}}{{Z}_{1}}\mathrm{cos}{\theta}_{2}}\\ {G}_{s}=\frac{{Z}_{2}\mathrm{cos}{\theta}_{1}-{Z}_{1}\mathrm{cos}{\theta}_{2}}{{Z}_{2}\mathrm{cos}{\theta}_{1}+{Z}_{1}\mathrm{cos}{\theta}_{2}}=\frac{\mathrm{cos}{\theta}_{2}-\frac{{Z}_{2}}{{Z}_{1}}\mathrm{cos}{\theta}_{1}}{\mathrm{cos}{\theta}_{2}+\frac{{Z}_{2}}{{Z}_{1}}\mathrm{cos}{\theta}_{1}}\\ {Z}_{1}=\sqrt{\frac{{\mu}_{1}}{{\epsilon}_{1}}}\\ {Z}_{2}=\sqrt{\frac{{\mu}_{2}}{{\epsilon}_{2}}}\end{array}$$

where *Z* is
the impedance of the medium. Because the magnetic permeability of
the ground is almost identical to that of air or free space, the ratio
of impedances depends primarily on the ratio of electric permittivities

$$\begin{array}{l}{G}_{p}=\frac{\sqrt{\rho}\mathrm{cos}{\theta}_{1}-\mathrm{cos}{\theta}_{2}}{\sqrt{\rho}\mathrm{cos}{\theta}_{1}+\mathrm{cos}{\theta}_{2}}\\ {G}_{s}=\frac{\sqrt{\rho}\mathrm{cos}{\theta}_{2}-\mathrm{cos}{\theta}_{1}}{\sqrt{\rho}\mathrm{cos}{\theta}_{2}+\mathrm{cos}{\theta}_{1}}\end{array}$$

where the quantity *ρ
= ε _{2}/ε_{1}* is
the

*ground relative permittivity*set by the

`GroundRelativePermittivity`

property.
The angle *θ*is the incidence angle and the angle

_{1}*θ*is the refraction angle at the boundary. You can determine

_{2}*θ*using Snell’s law of refraction.

_{2}After reflection, the full field is reconstructed from the parallel
and perpendicular components. The total ground plane attenuation, *L _{G}*,
is a combination of

*G*and

_{s}*G*.

_{p}When the origin and destination are stationary relative to each other, you can write the
output `Y`

of the object as *Y(t) = F(t-τ)/L*. The quantity *τ* is the signal delay and
*L* is the free-space path loss. The delay *τ* is
given by *R/c*. *R* is either the line-of-sight propagation path
distance or the reflected path distance, and *c* is the propagation speed.
The path loss

$${L}_{tworay}=\frac{{(4\pi R)}^{2}}{{\lambda}^{2}},$$

where *λ* is the signal wavelength.

### Atmospheric Gas Attenuation Model

This model calculates the attenuation of signals that propagate through atmospheric gases.

Electromagnetic signals attenuate when they propagate through the atmosphere. This effect is
due primarily to the absorption resonance lines of oxygen and water vapor, with smaller
contributions coming from nitrogen gas. The model also includes a continuous absorption
spectrum below 10 GHz. The ITU model *Recommendation ITU-R P.676-10: Attenuation by
atmospheric gases* is used. The model computes the specific attenuation
(attenuation per kilometer) as a function of temperature, pressure, water vapor density, and
signal frequency. The atmospheric gas model is valid for frequencies from 1–1000 GHz and
applies to polarized and nonpolarized fields.

The formula for specific attenuation at each frequency is

$$\gamma ={\gamma}_{o}(f)+{\gamma}_{w}(f)=0.1820f{N}^{\u2033}(f).$$

The quantity *N"()* is the imaginary part of the complex
atmospheric refractivity and consists of a spectral line component and a continuous component:

$${N}^{\u2033}(f)={\displaystyle \sum _{i}{S}_{i}{F}_{i}+{{N}^{\u2033}}_{D}^{}(f)}$$

The spectral component consists of a sum of discrete spectrum terms
composed of a localized frequency bandwidth function,
*F(f)*_{i}, multiplied by a spectral line strength,
*S*_{i}. For atmospheric oxygen, each spectral line
strength is

$${S}_{i}={a}_{1}\times {10}^{-7}{\left(\frac{300}{T}\right)}^{3}\mathrm{exp}\left[{a}_{2}(1-\left(\frac{300}{T}\right)\right]P.$$

For atmospheric water vapor, each spectral line strength is

$${S}_{i}={b}_{1}\times {10}^{-1}{\left(\frac{300}{T}\right)}^{3.5}\mathrm{exp}\left[{b}_{2}(1-\left(\frac{300}{T}\right)\right]W.$$

*P* is the dry air pressure, *W* is the
water vapor partial pressure, and *T* is the ambient temperature. Pressure
units are in hectoPascals (hPa) and temperature is in degrees Kelvin. The water vapor
partial pressure, *W*, is related to the water vapor density, ρ, by

$$W=\frac{\rho T}{216.7}.$$

The total atmospheric pressure is *P* +
*W*.

For each oxygen line, *S _{i}* depends on two parameters,

*a*and

_{1}*a*. Similarly, each water vapor line depends on two parameters,

_{2}*b*and

_{1}*b*. The ITU documentation cited at the end of this section contains tabulations of these parameters as functions of frequency.

_{2}The localized frequency bandwidth functions *F _{i}(f)* are
complicated functions of frequency described in the ITU references
cited below. The functions depend on empirical model parameters that
are also tabulated in the reference.

To compute the total attenuation for narrowband signals along
a path, the function multiplies the specific attenuation by the path
length, *R*. Then, the total attenuation is *L _{g}=
R(γ_{o} + γ_{w})*.

You can apply the attenuation model to wideband signals. First, divide the wideband signal into frequency subbands, and apply attenuation to each subband. Then, sum all attenuated subband signals into the total attenuated signal.

### Fog and Cloud Attenuation Model

This model calculates the attenuation of signals that propagate through fog or clouds.

Fog and cloud attenuation are the same atmospheric phenomenon. The ITU model,
*Recommendation ITU-R P.840-6: Attenuation due to clouds and fog* is
used. The model computes the specific attenuation (attenuation per kilometer), of a signal
as a function of liquid water density, signal frequency, and temperature. The model applies
to polarized and nonpolarized fields. The formula for specific attenuation at each frequency is

$${\gamma}_{c}={K}_{l}\left(f\right)M,$$

where *M* is the liquid water density in
gm/m^{3}. The quantity
*K _{l}(f)* is the specific attenuation coefficient
and depends on frequency. The cloud and fog attenuation model is valid for frequencies
10–1000 GHz. Units for the specific attenuation coefficient are
(dB/km)/(g/m

^{3}).

To compute the total attenuation for narrowband signals along
a path, the function multiplies the specific attenuation by the path
length *R*. Total attenuation is *L _{c} =
Rγ_{c}*.

You can apply the attenuation model to wideband signals. First, divide the wideband signal into frequency subbands, and apply narrowband attenuation to each subband. Then, sum all attenuated subband signals into the total attenuated signal.

### Rainfall Attenuation Model

This model calculates the attenuation of signals that propagate through regions of rainfall. Rain attenuation is a dominant fading mechanism and can vary from location-to-location and from year-to-year.

Electromagnetic signals are attenuated when propagating through a region of rainfall. Rainfall
attenuation is computed according to the ITU rainfall model *Recommendation
ITU-R P.838-3: Specific attenuation model for rain for use in prediction
methods*. The model computes the specific attenuation (attenuation
per kilometer) of a signal as a function of rainfall rate, signal frequency,
polarization, and path elevation angle. The specific attenuation,
*ɣ*_{R}, is modeled as a power law with
respect to rain rate

$${\gamma}_{R}=k{R}^{\alpha},$$

where *R* is rain rate. Units are in mm/hr. The
parameter *k* and exponent *α* depend on the
frequency, the polarization state, and the elevation angle of the signal path. The
specific attenuation model is valid for frequencies from 1–1000 GHz.

To compute the total attenuation for narrowband signals along a path, the function multiplies
the specific attenuation by the an effective propagation distance,
*d*_{eff}. Then, the total attenuation
is *L =
d*_{eff}*γ*_{R}.

The effective distance is the geometric distance, *d*, multiplied by
a scale factor

$$r=\frac{1}{0.477{d}^{0.633}{R}_{0.01}^{0.073\alpha}{f}^{0.123}-10.579\left(1-\mathrm{exp}\left(-0.024d\right)\right)}$$

where *f* is the frequency. The article
*Recommendation ITU-R P.530-17 (12/2017): Propagation data and
prediction methods required for the design of terrestrial line-of-sight
systems* presents a complete discussion for computing
attenuation.

The rain rate, *R*, used in these computations is the long-term
statistical rain rate, *R*_{0.01}. This is the
rain rate that is exceeded 0.01% of the time. The calculation of the statistical
rain rate is discussed in *Recommendation ITU-R P.837-7 (06/2017):
Characteristics of precipitation for propagation modelling*. This
article also explains how to compute the attenuation for other percentages from the
0.01% value.

You can apply the attenuation model to wideband signals. First, divide the wideband signal into frequency subbands and apply attenuation to each subband. Then, sum all attenuated subband signals into the total attenuated signal.

## References

[1] Saakian, A. *Radio Wave Propagation Fundamentals*.
Norwood, MA: Artech House, 2011.

[2] Balanis, C. *Advanced Engineering Electromagnetics*.
New York: Wiley & Sons, 1989.

[3] Rappaport, T. *Wireless Communications: Principles and Practice,
2nd Ed* New York: Prentice Hall, 2002.

[4] Radiocommunication Sector of the International Telecommunication Union.
*Recommendation ITU-R P.676-10: Attenuation by atmospheric
gases*. 2013.

[5] Radiocommunication Sector of the International Telecommunication Union.
*Recommendation ITU-R P.840-6: Attenuation due to clouds and
fog*. 2013.

[6] Radiocommunication Sector of the International Telecommunication Union.
*Recommendation ITU-R P.838-3: Specific attenuation model for rain for
use in prediction methods*. 2005.

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

Usage notes and limitations:

See System Objects in MATLAB Code Generation (MATLAB Coder).

## Version History

**Introduced in R2021a**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)