Fdocuments - in Phased Array Book
Fdocuments - in Phased Array Book
Fdocuments - in Phased Array Book
User's Guide
R2014b
How to Contact MathWorks
Phone: 508-647-7000
Revision History
April 2011 Online only Revised for Version 1.0 (R2011a)
September 2011 Online only Revised for Version 1.1 (R2011b)
March 2012 Online only Revised for Version 1.2 (R2012a)
September 2012 Online only Revised for Version 1.3 (R2012b)
March 2013 Online only Revised for Version 2.0 (R2013a)
September 2013 Online only Revised for Version 2.1 (R2013b)
March 2014 Online only Revised for Version 2.2 (R2014a)
October 2014 Online only Revised for Version 2.3 (R2014b)
Contents
Phased Arrays
iii
Array Geometries and Analysis
2
Uniform Linear Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Support for Uniform Linear Arrays . . . . . . . . . . . . . . . . 2-2
Positions of Elements in Array . . . . . . . . . . . . . . . . . . . 2-2
Identical Elements in Array . . . . . . . . . . . . . . . . . . . . . 2-3
Response of Array Elements . . . . . . . . . . . . . . . . . . . . . 2-4
Signal Delay Between Array Elements . . . . . . . . . . . . . 2-4
Steering Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Array Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Reception of Plane Wave Across Array . . . . . . . . . . . . . 2-7
iv Contents
Signal Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Support for Modeling Signal Collection . . . . . . . . . . . . . 3-4
Narrowband Collector for Uniform Linear Array . . . . . . 3-5
Narrowband Collector for a Single Antenna Element . . . 3-6
Wideband Signal Collection . . . . . . . . . . . . . . . . . . . . . . 3-7
v
Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
Transmitter Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
Phase Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25
Beamforming
5
Conventional Beamforming . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Uses for Beamformers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Support for Conventional Beamforming . . . . . . . . . . . . . . . . 5-2
Narrowband Phase Shift Beamformer with a ULA . . . . . . . . 5-2
vi Contents
Direction-of-Arrival (DOA) Estimation
6
Beamscan Direction-of-Arrival Estimation . . . . . . . . . . . . . . 6-2
Detection
8
Neyman-Pearson Hypothesis Testing . . . . . . . . . . . . . . . . . . . 8-2
Purpose of Hypothesis Testing . . . . . . . . . . . . . . . . . . . . . . . 8-2
Support for Neyman-Pearson Hypothesis Testing . . . . . . . . . 8-2
Threshold for Real-Valued Signal in White Gaussian Noise . . 8-3
vii
Threshold for Two Pulses of Real-Valued Signal in White
Gaussian Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
Threshold for Complex-Valued Signals in Complex White
Gaussian Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5
viii Contents
One-Way and Two-Way Propagation . . . . . . . . . . . . . . . . . . . 9-4
Propagation from Stationary Radar to Moving Target . . . . . . 9-5
ix
Motion Modeling in Phased Array Systems . . . . . . . . . . . . 10-29
Support for Motion Modeling . . . . . . . . . . . . . . . . . . . . . . . 10-29
Platform Motion with Constant Velocity . . . . . . . . . . . . . . 10-30
Platform Motion with Nonconstant Velocity . . . . . . . . . . . 10-31
Track Range and Angle Changes Between Platforms . . . . . 10-32
Using Polarization
11
Polarized Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
Introduction to Polarization . . . . . . . . . . . . . . . . . . . . . . . . 11-2
Linear and Circular Polarization . . . . . . . . . . . . . . . . . . . . . 11-4
Elliptic Polarization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
Linear and Circular Polarization Bases . . . . . . . . . . . . . . . 11-13
Sources of Polarized Fields . . . . . . . . . . . . . . . . . . . . . . . . 11-17
Scattering Cross-Section Matrix . . . . . . . . . . . . . . . . . . . . 11-24
Polarization Loss Due to Field and Receiver Mismatch . . . 11-27
Polarization Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-29
x Contents
Code Generation
13
Code Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2
Code Generation Use and Benefits . . . . . . . . . . . . . . . . . . . 13-2
Limitations Specific to Phased Array System Toolbox . . . . . 13-3
General Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6
Limitations for System Objects that Require Dynamic Memory
Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-11
xi
Process Tuned Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-27
xii Contents
Phased Arrays
1
In this section...
“Support for Isotropic Antenna Elements” on page 1-2
“Backbaffled Isotropic Antenna” on page 1-2
“Element Response of Backbaffled Isotropic Antenna Element” on page 1-4
You can find your isotropic antenna element’s voltage response at specific frequencies
and angles using the antenna element’s step method.
ha = phased.IsotropicAntennaElement(...
'FrequencyRange',[3e8 1e9],'BackBaffled',false)
plotResponse(ha,1e9,'RespCut','3D','Format','Polar',...
'Unit','pow');
1-2
Isotropic Antenna Element
figure;
plotResponse(ha,1e9);
Setting the BackBaffled property to true limits the response to azimuth angles in the
interval [–90,90].
1-3
1 Antenna and Microphone Elements
ha.BackBaffled=true;
figure;
plotResponse(ha,1e9,'RespCut','3D','Format','Polar',...
'Unit','pow');
Construct an isotropic antenna element to operate in the IEEE® X band between 8 and
12 GHz. Backbaffle the response of the antenna. Obtain your antenna element’s response
at 4 GHz intervals between 6 and 14 GHz and at azimuth angles between –100 and 100
in 50-degree increments.
ha = phased.IsotropicAntennaElement(...
'FrequencyRange',[8e9 12e9],'BackBaffled',true)
respfreqs = 6e9:4e9:14e9;
respazangles = -100:50:100;
anresp = step(ha,respfreqs,respazangles)
The antenna response in anresp is a matrix whose row dimension equals the number
of azimuth angles in respazangles and whose column dimension equals the number of
frequencies in respfreqs.
1-4
Isotropic Antenna Element
The response voltage in the first two and last two columns of anresp is zero because
those columns contain the antenna response at 6 and 14 GHz respectively. These
frequencies are not included in the antenna’s operating frequency range.
Similarly, the first and last rows of anresp contain all zeros because the BackBaffled
property is set to true. The first and last row contain the antenna’s response at azimuth
angles outside of [–90,90].
To obtain the antenna response at nonzero elevation angles, input the angles to step as
a 2-by-M matrix where each column is an angle in the form [azimuth;elevation].
release(ha)
respelangles = -90:45:90;
respangles = [respazangles; respelangles];
anresp = step(ha,respfreqs,respangles)
Note that anresp(1,2) and anresp(5,2) represent the antenna voltage response at
the aziumth-elevation pairs (–100,–90) and (100,90). Because the elevation angles are
equal to +/– 90 degrees, these responses are equal to one even though the BackBaffled
property is set to true. Thus, the resulting elevation cut degenerates into a point.
1-5
1 Antenna and Microphone Elements
In this expression:
The response is defined for azimuth and elevation angles between –90 and 90 degrees,
inclusive. There is no response at the back of a cosine antenna. The cosine response
pattern achieves a maximum value of 1 at 0 degrees azimuth and elevation. Raising the
response pattern to powers greater than one concentrates the response in azimuth or
elevation.
When you use the cosine antenna element, you specify the exponent of the cosine pattern
and the operating frequency range of the antenna.
1-6
Cosine Antenna Element
theta = -90:.01:90;
Cos1 = cosd(theta);
Cos2 = Cos1.^2;
plot(theta,Cos1); hold on;
plot(theta,Cos2,'r');
legend('Exponent = 1','Exponent = 2','location','northeast');
xlabel('Degrees'); ylabel('Response');
hcos = phased.CosineAntennaElement(...
'FrequencyRange',[1e9 1e10],'CosinePower',[2 2])
plotResponse(hcos,5e9,'RespCut','3D','Format','Polar');
1-7
1 Antenna and Microphone Elements
1-8
Custom Antenna Element
Tip You can import a radiation pattern that uses u/v coordinates or φ/θ
angles, instead of azimuth/elevation angles. To use such a pattern with
phased.CustomAntennaElement, first convert your pattern to azimuth/elevation
form. Use uv2azelpat or phitheta2azelpat to do the conversion. For an example,
see Antenna Array Analysis with Custom Radiation Pattern.
For your custom antenna element, the antenna response (the output of step) depends
on the frequency response and radiation pattern. Specifically, the frequency and spatial
responses are interpolated separately using nearest-neighbor interpolation and then
multiplied together to produce the total response. To avoid interpolation errors, the
range of azimuth angles should include +/– 180 degrees and the range of elevation angles
should include +/– 90 degrees.
1-9
1 Antenna and Microphone Elements
Az = -180:90:180;
El = -90:45:90;
Elresp = cosd(El);
ha = phased.CustomAntennaElement('AzimuthAngles',Az,...
'ElevationAngles',El,...
'RadiationPattern',repmat(Elresp',1,numel(Az)));
ha.RadiationPattern
Use the step method to calculate the antenna response at the azimuth-elevation pairs
[-30 0; -45 0]; for a frequency of 500 MHz.
The following illustrates the nearest-neighbor interpolation method used to find the
antenna voltage response.
G = interp2(degtorad(ha.AzimuthAngles),...
degtorad(ha.ElevationAngles),...
db2mag(ha.RadiationPattern),...
degtorad(ANG(1,:))', degtorad(ANG(2,:))','nearest',0);
H = interp1(ha.FrequencyVector,...
db2mag(ha.FrequencyResponse),5e8,'nearest',0);
antresp = H.*G
1-10
Omnidirectional Microphone
Omnidirectional Microphone
In this section...
“Support for Omnidirectional Microphones” on page 1-11
“Backbaffled Omnidirectional Microphone” on page 1-11
hmic = phased.OmnidirectionalMicrophoneElement(...
'BackBaffled',true,'FrequencyRange',[20 20e3]);
plotResponse(hmic,1e3,'RespCut','3D','Format','Polar',...
'Unit','pow');
1-11
1 Antenna and Microphone Elements
1-12
Omnidirectional Microphone
Use step to obtain the microphone’s magnitude response at the specified azimuth angles
and frequencies. The elevation angles are 0 degrees. Note the response is one at all
azimuth angles and frequencies as expected.
freq = 100:250:1e3;
ang = -90:30:90;
micresp = step(hmic,freq,ang)
1-13
1 Antenna and Microphone Elements
Related Examples
• “Microphone Array” on page 2-9
1-14
2
In this section...
“Support for Uniform Linear Arrays” on page 2-2
“Positions of Elements in Array” on page 2-2
“Identical Elements in Array” on page 2-3
“Response of Array Elements” on page 2-4
“Signal Delay Between Array Elements” on page 2-4
“Steering Vector” on page 2-5
“Array Response” on page 2-6
“Reception of Plane Wave Across Array” on page 2-7
hula = phased.ULA('NumElements',2,'ElementSpacing',0.5);
viewArray(hula);
2-2
Uniform Linear Array
You can return the coordinates of the array sensor elements in the form [x;y;z] by
using the getElementPosition method. See “Rectangular Coordinates” on page
10-2 for toolbox conventions.
sensorpos = getElementPosition(hula);
sensorpos is a 3-by-2 matrix with each column representing the position of a sensor
element. Note that the y-axis is the array axis. The positive x-axis is the array look
direction (0 degrees broadside). The elements are symmetric with the respect to the
phase center of the array.
2-3
2 Array Geometries and Analysis
The following example computes the delay between elements of a 4-element ULA for
a signal incident on the array from –90 degrees azimuth and zero degrees elevation.
The delays are computed with respect to the phase center of the array. By default,
phased.ElementDelay assumes that the incident waveform is an electromagnetic wave
propagating at the speed of light.
% Construct 4-element ULA using value-only syntax
hula = phased.ULA(4);
hdelay = phased.ElementDelay('SensorArray',hula);
tau = step(hdelay,[-90;0]);
tau is a 4-by-1 vector of delays with respect to the phase center of the array, which is
the origin of the local coordinate system [0;0;0]. See “Global and Local Coordinate
Systems” for a description of global and local coordinate systems. Negative delays
indicate that the signal arrives at an element before reaching the phase center of the
array. Because the waveform arrives from an azimuth angle of –90 degrees, the signal
2-4
Uniform Linear Array
impinges on the first and second elements of the ULA before it reaches the phase center
resulting in negative delays.
If the signal is incident on the array at 0 degrees broadside from a far-field source, the
signal illuminates all elements of the array simultaneously resulting in zero delay.
tau = step(hdelay,[0;0]);
If the incident signal is an acoustic pressure waveform propagating at the speed of sound,
you can calculate the element delays by specifying the PropagationSpeed property.
hdelay = phased.ElementDelay('SensorArray',hula,...
'PropagationSpeed',340);
tau = step(hdelay,[90;0]);
In the preceding code, the propagation speed is set to 340 m/s, which is the approximate
speed of sound at sea level.
Steering Vector
The steering vector represents the relative phase shifts for the incident far-field
waveform across the array elements. You can determine these phase shifts with the
phased.SteeringVector object.
For a single carrier frequency, the steering vector for a ULA consisting of N elements is:
Ê e- j 2p f t 1 ˆ
Á ˜
Á e- j 2p f t 2 ˜
Á ˜
Á e- j 2p f t 3 ˜
Á ˜
Á . ˜
Á . ˜
Á ˜
Á . ˜
ÁÁ - j 2p f t N ˜˜
Ëe ¯
where τn denotes the time delay relative to the array phase center at the n-th array
element.
Compute the steering vector for a 4-element ULA with an operating frequency of 1 GHz.
Assume that the waveform is incident on the array from 45 degrees azimuth and 10
degrees elevation.
2-5
2 Array Geometries and Analysis
hula = phased.ULA(4);
hsv = phased.SteeringVector('SensorArray',hula);
sv = step(hsv,1e9,[45; 10]);
You can obtain the steering vector with the following equivalent code.
hdelay = phased.ElementDelay('SensorArray',hula);
tau = step(hdelay,[45;10]);
exp(-1j*2*pi*1e9*tau)
Array Response
To obtain the array response, which is a weighted-combination of the steering vector
elements for each incident angle, use phased.ArrayResponse.
Construct a two-element ULA with elements spaced at 0.5 m. Obtain the array’s
magnitude response (absolute value of the complex-valued array response) for azimuth
angles -180:180 and plot the normalized magnitude response in decibels.
hula = phased.ULA('NumElements',2,'ElementSpacing',0.5);
azangles = -180:180;
har = phased.ArrayResponse('SensorArray',hula);
resp = abs(step(har,1e9,azangles));
plot(azangles,mag2db((resp/max(resp))));
grid on;
title('Azimuth Cut at Zero Degrees Elevation');
xlabel('Azimuth Angle (degrees)');
2-6
Uniform Linear Array
Visualize the array response using the plotResponse method. This example uses
options to create a 3-D plot of the response in u/v space; other plotting options are
available.
figure;
plotResponse(hula,1e9,physconst('LightSpeed'),...
'Format','UV','RespCut','3D')
The collectPlaneWave method modulates input signals by the element of the steering
vector corresponding to an array element. Stated differently, collectPlaneWave
accounts for phase shifts across elements in the array based on the angle of arrival.
However, collectPlaneWave does not account for the response of individual elements
in the array.
Simulate the reception of a 100-Hz sine wave modulated by a carrier frequency of 1 GHz
at a 4-element ULA. Assume the angle of arrival of the signal is [-90; 0].
hula = phased.ULA(4);
t = unigrid(0,0.001,0.01,'[)');
% signals must be column vectors
2-7
2 Array Geometries and Analysis
x = cos(2*pi*100*t)';
y = collectPlaneWave(hula,x,[-90;0],1e9,physconst('LightSpeed'));
Related Examples
• “Microphone Array” on page 2-9
2-8
Microphone Array
Microphone Array
This example shows how to construct and visualize a four-element ULA with custom
cardioid microphone elements.
Create a microphone element with a cardioid response pattern. Use the default
FrequencyVector of [20 20e3]. Specify the polar pattern frequencies as [500 1000].
Plot the polar pattern of the microphone at 0.5 kHz and 1 kHz.
plotResponse(hmic,freq,'Format','Polar');
Assign the custom microphone element as the Element property of a phased.ULA object.
ha = phased.ULA('NumElements',4,'ElementSpacing',0.5,...
'Element',hmic);
figure;
plotResponse(ha,freq,340,'Format','Polar')
2-9
2 Array Geometries and Analysis
2-10
Uniform Rectangular Array
In this section...
“Support for Uniform Rectangular Arrays” on page 2-11
“Uniform Rectangular Array with Isotropic Antenna Elements” on page 2-11
Create and view a six-element URA with two elements along the y-axis and three
elements along the z-axis. Use a rectangular lattice, with the default spacing of 0.5
meters along both the row and column dimensions of the array. Each element is an
isotropic antenna element, which is the default. Return the positions of the array
elements.
2-11
2 Array Geometries and Analysis
You can plot the array response using the plotResponse method.
Calculate the element delays for signals arriving from +/– 45 degrees azimuth and 0
degrees elevation.
hed = phased.ElementDelay('SensorArray',hura);
ang = [45 -45];
tau = step(hed,ang);
2-12
Uniform Rectangular Array
The first column of tau contains the element delays for the signal incident on the array
from +45 degrees azimuth and the second column contains the delays for the signal
arriving from –45 degrees. The delays are equal in magnitude but opposite in sign as
expected.
The following code simulates the reception of two sine waves arriving from far field
sources. One of the signals is a 100-Hz sine wave arriving from 20 degrees azimuth and
10 degrees elevation. The other signal is a 300-Hz sine wave arriving from –30 degrees
azimuth and 5 degrees elevation. Both signals have a one GHz carrier frequency.
t = linspace(0,1,1000);
x = cos(2*pi*100*t)';
y = cos(2*pi*300*t)';
angx = [20; 10];
angy = [-30;5];
recsig = collectPlaneWave(hura,[x y],[angx angy],1e9);
Each column of recsig represents the received signal at the corresponding element of
the URA, hura.
2-13
2 Array Geometries and Analysis
Conformal Array
In this section...
“Support for Arrays with Custom Geometry” on page 2-14
“Uniform Circular Array” on page 2-14
“Custom Antenna Array” on page 2-16
When you use phased.ConformalArray, you must specify these aspects of the array:
hcon = phased.ConformalArray
2-14
Conformal Array
viewArray(hcirc);
figure;
plotResponse(hcirc,1e9,physconst('LightSpeed'),'Format','Polar')
2-15
2 Array Geometries and Analysis
2-16
Conformal Array
Define the locations and normal directions of the elements. In this case, the elements are
located at [1;0;0], [0;1;0], and [0;-1;0]. The element normal azimuth angles are 0,
120, and –120 degrees respectively. All normal elevation angles are 0 degrees.
xpos = [1 0 0];
ypos = [0 1 -1];
zpos = [0 0 0];
normal_az = [0 120 -120];
normal_el = [0 0 0];
ha = phased.ConformalArray('Element',hele,...
'ElementPosition',[xpos; ypos; zpos],...
'ElementNormal',[normal_az; normal_el]);
figure;
viewArray(ha,'ShowNormals',true)
view(0,90)
2-17
2 Array Geometries and Analysis
2-18
Subarrays Within Arrays
Definition of Subarrays
In Phased Array System Toolbox™ software, a subarray is an accessible subset of array
elements. When you use an array that contains subarrays, you can access measurements
from the subarrays but not from the individual elements. Similarly, you can perform
processing at the subarray level but not at the level of the individual elements. As a
result, the system has fewer degrees of freedom than if you controlled the system at the
level of the individual elements.
• Define one subarray, and then build a larger array by arranging copies of the
subarray. The subarray can be a ULA, URA, or conformal array. The copies are
identical, except for their location and orientation. You can arrange the copies
spatially in a grid or a custom layout.
2-19
2 Array Geometries and Analysis
When you use this approach, you build the large array by creating a
phased.ReplicatedSubarray System object™. This object stores information
about the subarray and how the copies of it are arranged to form the larger array.
• Define an array, and then partition it into subarrays. The array can be a ULA, URA,
or conformal array. The subarrays do not need to be identical. A given array element
can be in more than one subarray, leading to overlapped subarrays.
When you use this approach, you partition your array by creating a
phased.PartitionedArray System object. This object stores information about the
array and its subarray structure.
• phased.AngleDopplerResponse
• phased.ArrayGain
• phased.ArrayResponse
• phased.Collector
• phased.ConstantGammaClutter
• phased.MVDRBeamformer
• phased.PhaseShiftBeamformer
• phased.Radiator
• phased.STAPSMIBeamformer
• phased.SteeringVector
• phased.SubbandPhaseShiftBeamformer
• phased.WidebandCollector
2-20
Subarrays Within Arrays
ha = phased.URA('Size',[2 3]);
Plot the positions of the array elements in the yz plane. (All the x coordinates are zero.)
Include labels that indicate the numbering of the elements. The numbering is important
for selecting which elements are in each subarray.
viewArray(ha,'ShowIndex','All')
Create and view an array consisting of three 2-element linear subarrays each
parallel to the z-axis. Use the numbers in the plot to help form the matrix for the
SubarraySelection property. Also, find the phase centers of the three subarrays.
subarray1 = [1 1 0 0 0 0; 0 0 1 1 0 0; 0 0 0 0 1 1];
2-21
2 Array Geometries and Analysis
hpa1 = phased.PartitionedArray('Array',ha,...
'SubarraySelection',subarray1);
subarraypos1 = getSubarrayPosition(hpa1);
figure;
viewArray(hpa1)
Create and view another array consisting of two 3-element linear subarrays parallel to
the y-axis. Find the phase centers of the two subarrays.
subarray2 = [0 1 0 1 0 1; 1 0 1 0 1 0];
hpa2 = phased.PartitionedArray('Array',ha,...
'SubarraySelection',subarray2);
subarraypos2 = getSubarrayPosition(hpa2);
figure;
viewArray(hpa2)
2-22
Subarrays Within Arrays
ha = phased.ULA('NumElements',4);
hrs = phased.ReplicatedSubarray('Subarray',ha,...
'GridSize',[2 1]);
Plot the positions of the array elements and the phase centers of the subarrays. The plot
is in the yz plane because all the x coordinates are zero.
viewArray(hrs);
hold on;
2-23
2 Array Geometries and Analysis
subarraypos = getSubarrayPosition(hrs);
sx = subarraypos(1,:);
sy = subarraypos(2,:);
sz = subarraypos(3,:);
scatter3(sx,sy,sz,'r*');
hold off
Create a larger array by arranging three copies of the linear array. Define the phase
centers and normal directions of the three copies explicitly.
vertex_ang = [60 180 -60];
vertex = 2*[cosd(vertex_ang); sind(vertex_ang); zeros(1,3)];
2-24
Subarrays Within Arrays
subarray_pos = 1/2*[...
(vertex(:,1)+vertex(:,2)) ...
(vertex(:,2)+vertex(:,3)) ...
(vertex(:,3)+vertex(:,1))];
hrs = phased.ReplicatedSubarray('Subarray',ha,...
'Layout','Custom',...
'SubarrayPosition',subarray_pos,...
'SubarrayNormal',[120 0;-120 0;0 0].');
Plot the positions of the array elements and the phase centers of the subarrays. The plot
is in the xy plane because all the z coordinates are zero.
viewArray(hrs,'ShowSubarray',[]);
hold on;
scatter3(subarray_pos(1,:),subarray_pos(2,:),...
subarray_pos(3,:),'r*');
hold off
Related Examples
• Subarrays in Phased Array Antennas
2-25
2-26
3
Signal Radiation
In this section...
“Support for Modeling Signal Radiation” on page 3-2
“Radiate Signal with Uniform Linear Array” on page 3-2
To radiate a signal from a sensor array, use phased.Radiator. When you use this
object, you must specify these aspects of the radiator:
3-2
Signal Radiation
The far field signal results from multiplying the signal by the array pattern. The array
pattern is the product of the array element pattern and the array factor. For a uniform
linear array, the array factor is the superposition of elements in the steering vector (see
phased.SteeringVector).
The following code produces an identical far field signal by explicitly using the array
factor.
hula = phased.ULA('NumElements',2,'ElementSpacing',0.5);
hsv = phased.SteeringVector('SensorArray',hula,...
'IncludeElementResponse',true);
sv = step(hsv,3e8,[45;0]);
y1 = x*sum(sv);
% compare y1 to y
3-3
3 Signal Radiation and Collection
Signal Collection
In this section...
“Support for Modeling Signal Collection” on page 3-4
“Narrowband Collector for Uniform Linear Array” on page 3-5
“Narrowband Collector for a Single Antenna Element” on page 3-6
“Wideband Signal Collection” on page 3-7
In many array processing applications, the ratio of the signal’s bandwidth to the
carrier frequency is small. Expressed as a percentage, this ratio does not exceed a few
percent. Examples include radar applications where a pulse waveform is modulated
by a carrier frequency in the microwave range. These are narrowband signals. For
narrowband signals, you can express the steering vector as a function of a single
frequency, the carrier frequency. For narrowband signals, the phased.Collector object
is appropriate.
When you use the narrowband collector, phased.Collector, you must specify these
aspects of the collector:
3-4
Signal Collection
When you use the wideband collector, phased.WidebandCollector, you must specify
these aspects of the collector:
• Carrier frequency
• Whether the signal is demodulated to the baseband
• Operating frequency of the array
• Propagation speed of the wave
• Sampling rate
• Sensor (single element) or sensor array
• Type of incoming wave. Choices are 'Plane' and 'Unspecified'. If you select
'Plane', the input signals are multiple plane waves impinging on the entire array.
Each plane wave is received by all collecting elements. If you select 'Unspecified',
the input signal are individual waves impinging on individual sensors.
• Whether to apply weights to signals collected by different elements in the array. If
you want to apply weights, you specify them when you call the step method.
hula = phased.ULA('NumElements',2,'ElementSpacing',0.5);
hcol = phased.Collector('Sensor',hula,...
'PropagationSpeed',physconst('LightSpeed'),...
'OperatingFrequency',3e8,'Wavefront','Plane')
% create signal to create
x =[1 -1 1 -1]';
% simulate reception from an angle of [45;0]
y = step(hcol,x,[45;0]);
3-5
3 Signal Radiation and Collection
In the preceding case, the collector object multiplies the input signal, x, by the
corresponding element of the steering vector for the two-element ULA. The following code
produces the response in an equivalent manner.
% default ULA
hula = phased.ULA('NumElements',2,'ElementSpacing',0.5);
% Construct steering vector
hsv = phased.SteeringVector('SensorArray',hula);
sv = step(hsv,3e8,[45;0]);
x =[1 -1 1 -1]';
y1 = x*sv.';
% compare y1 to y
ha = phased.CustomAntennaElement;
ha.AzimuthAngles = -180:180;
ha.ElevationAngles = -90:90;
ha.RadiationPattern = mag2db(...
repmat(cosd(ha.ElevationAngles)',1,numel(ha.AzimuthAngles)));
plotResponse(ha,1e9,'Format','polar','RespCut','El');
resp = step(ha,1e9,[0; 45])
3-6
Signal Collection
The antenna voltage response at zero degrees azimuth and 45 degrees elevation is
cosd(45) as expected.
Assume a narrowband sinusoidal input incident on the antenna element from 0 degrees
azimuth and 45 degrees elevation. Determine the signal collected at the element.
hc = phased.Collector('Sensor',ha,'OperatingFrequency',1e9)
x =[1 -1 1 -1]';
y = step(hc,x,[0; 45]);
% equivalent to y1 = x*cosd(45);
3-7
3-8
4
In this section...
“Definition of Rectangular Pulse Waveform” on page 4-2
“How to Create Rectangular Pulse Waveforms” on page 4-2
“Rectangular Waveform Plot” on page 4-3
“Pulses of Rectangular Waveform” on page 4-4
1 0 ≤ t ≤ t
a( t) =
0 otherwise
where ωc denotes the carrier frequency. Note that a(t) represents an on-off rectangular
amplitude modulation of the carrier frequency. After demodulation, the complex envelope
of x(t) is the real-valued rectangular pulse a(t) of duration τ seconds.
• Sampling rate
• Pulse duration
• Pulse repetition frequency
• Number of samples or pulses in each vector that represents the waveform
4-2
Rectangular Pulse Waveforms
hrect = phased.RectangularWaveform('SampleRate',1e6,...
'PulseWidth',5e-5,'PRF',1e4);
Plot a single rectangular pulse by calling plot directly on the rectangular waveform
variable.
figure;
plot(hrect)
bw = bandwidth(hrect);
4-3
4 Waveforms, Transmitter, and Receiver
Create a rectangular pulse with a duration of 100 μs and a PRF of 1 kHz. Set the number
of pulses in the output equal to two.
hrect = phased.RectangularWaveform('PulseWidth',100e-6,...
'PRF',1e3,'OutputFormat','Pulses','NumPulses',2);
Make a copy of your rectangular pulse and change the pulse width in your original
waveform to 10 μs.
hrect1 = clone(hrect);
hrect.PulseWidth = 10e-6;
hrect1 and hrect now specify different rectangular pulses because you changed the
pulse width of hrect.
Use the step method to return two pulses of your rectangular pulse waveforms.
y = step(hrect);
y1 = step(hrect1);
totaldur = 2*1/hrect.PRF;
totnumsamp = totaldur*hrect.SampleRate;
t = unigrid(0,1/hrect.SampleRate,totaldur,'[)');
subplot(2,1,1)
plot(t.*1000,real(y)); axis([0 totaldur*1e3 0 1.5]);
title('Two 10-\musec duration pulses (PRF = 1 kHz)');
set(gca,'XTick',0:0.2:totaldur*1e3)
subplot(2,1,2);
plot(t.*1000,real(y1)); axis([0 totaldur*1e3 0 1.5]);
xlabel('Milliseconds');
title('Two 100-\musec duration pulses (PRF = 1 kHz)');
set(gca,'XTick',0:0.2:totaldur*1e3)
4-4
Rectangular Pulse Waveforms
4-5
4 Waveforms, Transmitter, and Receiver
In this section...
“Benefits of Using Linear FM Pulse Waveform” on page 4-6
“Definition of Linear FM Pulse Waveform” on page 4-6
“How to Create Linear FM Pulse Waveforms” on page 4-7
“Configuration of Linear FM Pulse Waveform” on page 4-8
“Linear FM Pulse Waveform Plots” on page 4-8
“Ambiguity Function of Linear FM Waveform” on page 4-10
“Comparing Autocorrelation for Rectangular and Linear FM Waveforms” on page
4-11
For a rectangular pulse, the duration of the transmitted pulse and the processed echo are
effectively the same. Therefore, the range resolution of the radar and the target detection
capability are coupled in an inverse relationship.
Pulse compression techniques enable you to decouple the duration of the pulse from its
energy by effectively creating different durations for the transmitted pulse and processed
echo. Using a linear frequency modulated pulse waveform is a popular choice for pulse
compression.
2
x% (t) = a(t) e jp ( b /t ) t
4-6
Linear Frequency Modulated Pulse Waveforms
1 dΘ(t) b
= t
2p dt t
• Sample rate
• Duration of a single pulse
• Pulse repetition frequency
• Sweep bandwidth
• Sweep direction (up or down), corresponding to increasing and decreasing
instantaneous frequency
• Envelope, which describes the amplitude modulation of the pulse waveform. The
envelope can be rectangular or Gaussian.
1 0 ≤ t ≤ t
a( t) =
0 otherwise
4-7
4 Waveforms, Transmitter, and Receiver
2 2
a( t) = e-t /t t≥0
Create a linear FM pulse with a sample rate of 1 MHz, a pulse duration of 50 μs with an
increasing instantaneous frequency, and a sweep bandwidth of 100 kHz. The amplitude
modulation is rectangular.
hfm1 = phased.LinearFMWaveform('SampleRate',1e6,...
'PulseWidth',5e-5,'PRF',1e4,...
'SweepBandwidth',1e5,'SweepDirection','Up',...
'Envelope','Rectangular',...
'OutputFormat','Pulses','NumPulses',1);
Design a linear FM pulse waveform with a duration of 100 μs, a bandwidth of 200 kHz,
and a PRF of 1 kHz. Use the default values for the other properties. Compute the time-
bandwidth product and plot the real part of the pulse waveform.
hfm = phased.LinearFMWaveform('PulseWidth',100e-6,...
'SweepBandwidth',2e5,'PRF',1e3);
disp(hfm.PulseWidth*hfm.SweepBandwidth)
plot(hfm)
4-8
Linear Frequency Modulated Pulse Waveforms
Use the step method to obtain your pulse waveform signal. Plot the real and imaginary
parts of one pulse repetition interval.
y = step(hfm);
t = unigrid(0,1/hfm.SampleRate,1/hfm.PRF,'[)');
figure;
subplot(2,1,1)
plot(t,real(y))
axis tight;
title('Real Part');
subplot(2,1,2);
plot(t,imag(y)); xlabel('Seconds');
title('Imaginary Part');
axis tight;
4-9
4 Waveforms, Transmitter, and Receiver
hlfm = phased.LinearFMWaveform('PulseWidth',100e-6,...
'SweepBandwidth',2e5,'PRF',1e3);
x = step(hlfm);
Create a 3-D surface plot of the ambiguity function for the waveform.
[afmag_lfm,delay_lfm,doppler_lfm] = ambgfun(x,...
hlfm.SampleRate,hlfm.PRF);
surf(delay_lfm*1e6,doppler_lfm/1e3,afmag_lfm,...
'LineStyle','none');
axis tight; grid on; view([140,35]); colorbar;
xlabel('Delay \tau (\mus)');
ylabel('Doppler f_d (kHz)');
title('Linear FM Pulse Waveform Ambiguity Function');
4-10
Linear Frequency Modulated Pulse Waveforms
The surface has a narrow ridge that is slightly tilted. The tilt indicates better resolution
in the zero delay cut. For a more detailed analysis of waveforms using the ambiguity
function, see “Waveform Analysis Using the Ambiguity Function”.
Create a rectangular waveform and a linear FM pulse waveform having the same
duration and PRF. Generate samples of each waveform.
hrect = phased.RectangularWaveform('PRF',2e4);
hfm = phased.LinearFMWaveform('PRF',2e4);
xrect = step(hrect);
xfm = step(hfm);
[ambrect,delay] = ambgfun(xrect,hrect.SampleRate,hrect.PRF,...
'Cut','Doppler');
ambfm = ambgfun(xfm,hfm.SampleRate,hfm.PRF,...
'Cut','Doppler');
subplot(211);
4-11
4 Waveforms, Transmitter, and Receiver
stem(delay,ambrect)
title('Autocorrelation of Rectangular Pulse');
axis([-5e-5 5e-5 0 1]); set(gca,'XTick',1e-5 * (-5:5))
subplot(212);
stem(delay,ambfm)
xlabel('Delay (seconds)');
title('Autocorrelation of Linear FM Pulse');
axis([-5e-5 5e-5 0 1]); set(gca,'XTick',1e-5 * (-5:5))
Related Examples
• “Waveform Analysis Using the Ambiguity Function”
4-12
Stepped FM Pulse Waveforms
Similar to linear FM pulse waveforms, stepped frequency waveforms are a popular pulse
compression technique. Using this approach enables you to increase the range resolution
of the radar without sacrificing target detection capability.
The stepped frequency pulse waveform has the following modifiable properties:
Enter the following to construct a stepped FM pulse waveform with a pulse duration
(width) of 50 μs, a PRF of 10 kHz, and five steps of 20 kHz. The sampling rate is 1 MHz.
By default the OutputFormat property is equal to 'Pulses' and the number of pulses
in the output is equal to one. The example uses the bandwidth method to demonstrate
that the bandwidth of the stepped FM pulse waveform is the product of the frequency
step and the number of steps Obj.FrequencyStep*Obj.Numsteps.
hs = phased.SteppedFMWaveform('SampleRate',1e6,...
'PulseWidth',5e-5,'PRF',1e4,...
'FrequencyStep',2e4,'NumSteps',5);
bandwidth(hs)
% equal to hs.NumSteps*hs.FrequencyStep
Because the OutputFormat property is set to 'Pulses' and the NumPulses property is
set to 1, calling the step method returns one pulse repetition interval (PRI). The pulse
4-13
4 Waveforms, Transmitter, and Receiver
duration within that interval is equal to the PulseWidth property. The remainder of the
PRI consists of zeros.
The initial pulse has a frequency of zero, and is a DC pulse. With the NumPulses
property set to 1, each time you use step, the frequency of the narrowband pulse
increments by the value of the FrequencyStep property. If you call step more times
than the value of the NumSteps property, the process repeats, starting over with the DC
pulse.
Use step to return successively higher frequency pulses. Plot the pulses one by one in
the same figure window. Pause the loop to visualize the increment in frequency with each
successive call to step. Make an additional call to step to demonstrate that the process
starts over with the DC (rectangular) pulse.
t = unigrid(0,1/hs.SampleRate,1/hs.PRF,'[)');
for i = 1:hs.NumSteps
plot(t,real(step(hs)));
pause(0.5);
axis tight;
end
% calling step again starts over with a DC pulse
y = step(hs);
The next figure shows the plot in the final iteration of the loop.
4-14
FMCW Waveforms
FMCW Waveforms
In this section...
“Benefits of Using FMCW Waveform” on page 4-15
“How to Create FMCW Waveforms” on page 4-15
“Double Triangular Sweep” on page 4-16
• Sample rate.
• Period and bandwidth of the FM sweep. These quantities can cycle through multiple
values during your simulation.
Tip To find targets up to a given maximum range, r, you can typically use a sweep
period of approximately 5*range2time(r) or 6*range2time(r). To achieve a
range resolution of delta_r, use a bandwidth of at least range2bw(delta_r).
• Sweep shape. This shape can be sawtooth (up or down) or triangular.
Tip For moving targets, you can use a triangular sweep to resolve ambiguity between
range and Doppler.
4-15
4 Waveforms, Transmitter, and Receiver
Compute samples from four sweeps (two periods). In a triangular sweep, each period
consists of an up sweep and down sweep.
x = step(h);
Plot a spectrogram.
[S,F,T] = spectrogram(x,32,16,32,h.SampleRate);
image(T,fftshift(F),fftshift(mag2db(abs(S))))
xlabel('Time'); ylabel('Frequency (Hz)');
4-16
Phase-Coded Waveforms
Phase-Coded Waveforms
In this section...
“When to Use Phase-Coded Waveforms” on page 4-17
“How to Create Phase-Coded Waveforms” on page 4-17
“Basic Radar Using Phase-Coded Waveform” on page 4-18
Conversely, you might use another waveform instead of a phase-coded waveform in the
following situations:
Phase-coded waveforms tend to perform poorly when signals have Doppler shifts.
• When the hardware requirements for phase-coded waveforms are prohibitively
expensive
4-17
4 Waveforms, Transmitter, and Receiver
• Sample rate
• Pulse repetition frequency (PRF)
• Sequence index (Zadoff-Chu code only)
After you create a phased.PhaseCodedWaveform object, you can plot the waveform
using the plot method of this class. You can also generate samples of the waveform
using the step method.
For convenience, the complete code appears here. For a detailed explanation of the code,
see the original example, “End-to-End Radar System”.
hwav = phased.PhaseCodedWaveform('Code','Frank','NumChips',4,...
'ChipWidth',1e-6,'PRF',5e3,'OutputFormat','Pulses',...
'NumPulses',1);
hant = phased.IsotropicAntennaElement('FrequencyRange',...
[1e9 10e9]);
htgt = phased.RadarTarget('Model','Nonfluctuating',...
'MeanRCS',0.5,'PropagationSpeed',physconst('LightSpeed'),...
'OperatingFrequency',4e9);
htxplat = phased.Platform('InitialPosition',[0;0;0],...
'Velocity',[0;0;0],'OrientationAxes',[1 0 0;0 1 0;0 0 1]);
htgtplat = phased.Platform('InitialPosition',[7000; 5000; 0],...
'Velocity',[-15;-10;0]);
4-18
Phase-Coded Waveforms
[tgtrng,tgtang] = rangeangle(htgtplat.InitialPosition,...
htxplat.InitialPosition);
Pd = 0.9;
Pfa = 1e-6;
numpulses = 10;
SNR = albersheim(Pd,Pfa,10);
maxrange = 1.5e4;
lambda = physconst('LightSpeed')/4e9;
tau = hwav.ChipWidth * hwav.NumChips;
Pt = radareqpow(lambda,maxrange,SNR,tau,'RCS',0.5,'Gain',20);
htx = phased.Transmitter('PeakPower',50e3,'Gain',20,...
'LossFactor',0,'InUseOutputPort',true,...
'CoherentOnTransmit',true);
hrad = phased.Radiator('Sensor',hant,...
'PropagationSpeed',physconst('LightSpeed'),...
'OperatingFrequency',4e9);
hcol = phased.Collector('Sensor',hant,...
'PropagationSpeed',physconst('LightSpeed'),...
'Wavefront','Plane','OperatingFrequency',4e9);
hrec = phased.ReceiverPreamp('Gain',20,'NoiseFigure',2,...
'ReferenceTemperature',290,'SampleRate',1e6,...
'EnableInputPort',true,'SeedSource','Property','Seed',1e3);
hspace = phased.FreeSpace(...
'PropagationSpeed',physconst('LightSpeed'),...
'OperatingFrequency',4e9,'TwoWayPropagation',false,...
'SampleRate',1e6);
for n = 1:numpulses
% Update the target position
[tgtpos,tgtvel] = step(htgtplat,T);
4-19
4 Waveforms, Transmitter, and Receiver
rxsig = pulsint(rxsig,'noncoherent');
t = unigrid(0,1/hrec.SampleRate,T,'[)');
rangegates = (physconst('LightSpeed')*t)/2;
plot(rangegates,rxsig); hold on;
xlabel('Meters'); ylabel('Power');
ylim = get(gca,'YLim');
plot([tgtrng,tgtrng],[0 ylim(2)],'r');
4-20
Waveforms with Staggered PRFs
In this section...
“When to Use Staggered PRFs” on page 4-21
“Linear FM Waveform with Staggered PRF” on page 4-21
• The removal of Doppler ambiguities, or blind speeds, where Doppler frequencies that
are multiples of the PRF are aliased to zero
• Mitigation of the effects of jamming
To implement a staggered PRF, configure your waveform object with a vector instead of a
scalar as the PRF property value.
4-21
4 Waveforms, Transmitter, and Receiver
4-22
Transmitter
Transmitter
In this section...
“Transmitter Object” on page 4-23
“Phase Noise” on page 4-25
Transmitter Object
The phased.Transmitter object enables you to model key components of the radar
equation including the peak transmit power, the transmit gain, and a system loss factor.
You can use phased.Transmitter together with radareqpow, radareqrng, and
radareqsnr, to relate the received echo power to your transmitter specifications.
A transmitter that applies a random phase to each pulse creates phase noise that can
obscure Doppler shifts. If the components of the radar do not enable you to maintain
constant phase, you can create a pseudo-coherent, or coherent on receive radar by
keeping a record of the random phase errors introduced by the transmitter. The
receiver can correct for these errors by modulation of the complex envelope. The
phased.Transmitter object enables you to model both coherent on transmit and
coherent on receive behavior.
4-23
4 Waveforms, Transmitter, and Receiver
Construct a transmitter with a peak transmit power of 1000 watts, a transmit gain of 20
decibels (dB), and a loss factor of 0 dB. Set the InUseOutPutPort property to true to
record the transmitter's status.
htx = phased.Transmitter('PeakPower',1e3,'Gain',20,...
'LossFactor',0,'InUseOutputPort',true)
hpuls = phased.LinearFMWaveform('PulseWidth',100e-6,'PRF',2e3,...
'SweepBandwidth',2e5,'OutputFormat','Pulses','NumPulses',1);
Obtain the pulse waveform using the step method of the waveform object. Transmit
the waveform using the step method of the transmitter object, hpuls. The output
is one pulse repetition interval because the NumPulses property of the waveform
object is equal to 1. The pulse waveform values are scaled based on the peak transmit
power and the ratio of the transmitter gain to loss factor. The scaling factor is
sqrt(htx.PeakPower*db2pow(htx.Gain-htx.LossFactor)).
wf = step(hpuls);
[txoutput,txstatus] = step(htx,wf);
t = unigrid(0,1/hpuls.SampleRate,1/hpuls.PRF,'[)');
subplot(211)
plot(t,real(txoutput));
axis tight; grid on; ylabel('Amplitude');
title('Transmitter Output (real part) - One PRI');
subplot(212)
plot(t,txstatus);
axis([0 t(end) 0 1.5]); xlabel('Seconds'); grid on;
ylabel('Off-On Status');
4-24
Transmitter
set(gca,'ytick',[0 1]);
title('Transmitter Status');
Phase Noise
To model a coherent on receive radar, you can set the CoherentOnTransmit property to
false and the PhaseNoiseOutputPort property to true. You can output the random
phase added to each sample with step.
To illustrate this process, the following example uses a rectangular pulse waveform
with five pulses. A random phase is added to each sample of the waveform. Compute the
phase of the output waveform and compare the phase to the phase noise returned by the
step method.
For convenience, set the gain of the transmitter to 0 dB, the peak power to 1 W, and seed
the random number generator to ensure reproducible results.
hrect = phased.RectangularWaveform('NumPulses',5);
htx = phased.Transmitter('CoherentOnTransmit',false,...
'PhaseNoiseOutputPort',true,'Gain',0,'PeakPower',1,...
'SeedSource','Property','Seed',1000);
wf = step(hrect);
[txtoutput,phnoise] = step(htx,wf);
phdeg = radtodeg(phnoise);
phdeg(phdeg>180)= phdeg(phdeg>180)-360;
plot(wf); title('Input Waveform');
axis([0 length(wf) 0 1.5]); ylabel('Amplitude');
grid on;
4-25
4 Waveforms, Transmitter, and Receiver
figure;
subplot(2,1,1)
plot(radtodeg(atan2(imag(txtoutput),real(txtoutput))))
title('Phase of the Output'); ylabel('Degrees');
axis([0 length(wf) -180 180]); grid on;
subplot(2,1,2)
plot(phdeg); title('Phase Noise'); ylabel('Degrees');
axis([0 length(wf) -180 180]); grid on;
4-26
Transmitter
The first figure shows the waveform. The phase of each pulse at the input to the
transmitter is zero. In the second figure, the top plot shows the phase of the transmitter
output waveform. The bottom plot shows the phase added to each sample. Focus on the
first 100 samples. The pulse waveform is equal to 1 for samples 1–50 and 0 for samples
51–100. The added random phase is a constant –124.7 degrees for samples 1–100, but
this affects the output only when the pulse waveform is nonzero. In the output waveform,
you see that the output waveform has a phase of –124.7 degrees for samples 1–50 and
4-27
4 Waveforms, Transmitter, and Receiver
0 for 51–100. Examining the transmitter output and phase noise for samples where the
input waveform is nonzero, you see that the phase output of step and the phase of the
transmitter output agree.
4-28
Receiver Preamp
Receiver Preamp
In this section...
“Operation of Receiver Preamp” on page 4-29
“Configuring Receiver Preamp” on page 4-29
“Model Receiver Effects on Sinusoidal Input” on page 4-30
“Model Coherent on Receive Behavior” on page 4-32
• EnableInputPort — A logical property that enables you to specify when the receiver
is on or off. Input the actual status of the receiver as a vector to step. This property
is useful when modeling a monostatic radar system. In a monostatic radar, it is
important to ensure the transmitter and receiver are not operating simultaneously.
See phased.Transmitter and “Transmitter” on page 4-23.
• Gain — Gain in dB
• LossFactor — Loss factor in dB.
• NoiseFigure — Receiver noise figure in dB
• ReferenceTemperature — Reference temperature of the receiver in kelvin
• EnableInputPort — Add input to specify when the receiver is active
• PhaseNoiseInputPort — Add input to specify phase noise for coherent on receive
receiver
• SeedSource — Enables you to specify the seed of the random number generator
The noise figure is a dimensionless quantity that indicates how much a receiver deviates
from an ideal receiver in terms of internal noise. An ideal receiver only produces the
4-29
4 Waveforms, Transmitter, and Receiver
expected thermal noise power for a given noise bandwidth and temperature. A noise
figure of 1 indicates that the noise power of a receiver equals the noise power of an ideal
receiver. Because an actual receiver cannot exhibit a noise power value less than an ideal
receiver, the noise figure is always greater than or equal to one. In decibels, the noise
figure must be nonnegative.
The additive noise for the receiver is modeled as a zero-mean complex white Gaussian
noise vector with variance equal to the noise power. The real and imaginary parts of the
noise vector each have variance equal to 1/2 the noise power.
The signal is scaled by the ratio of the receiver gain to the loss factor expressed as a
power ratio. If you express the gain and loss factor as powers by G and L respectively and
the noise power as σ2, the output is equal to :
G s
y[ n] = x[ n ] + w[ n ]
L 2
where x[n] is the complex-valued input signal and w[n] is a zero-mean complex white
Gaussian noise sequence.
hr = phased.ReceiverPreamp('Gain',20,...
'NoiseFigure',5,'ReferenceTemperature',290,...
'SampleRate',1e6,'SeedSource','Property','Seed',1e3);
Assume a 100-Hz sine wave input with an amplitude of 1 microvolt. Because the Phased
Array System Toolbox assumes that all modeling is done at baseband, use a complex
exponential as the input to the phased.ReceiverPreamp.step method.
4-30
Receiver Preamp
t = unigrid(0,0.001,0.1,'[)');
x = 1e-6*exp(1j*2*pi*100*t).';
y = step(hr,x);
Now show how the same output can produced from a multiplicative gain and additive
noise. First assume that the noise bandwidth equals the sample rate of the receiver
preamp (1 MHz). Then, the noise power is equal to:
NoiseBandwidth = hr.SampleRate;
noisepow = physconst('Boltzmann')*...
systemp(hr.NoiseFigure,hr.ReferenceTemperature)*NoiseBandwidth;
The noise power is the variance of the additive white noise. To determine the correct
amplitude scaling of the input signal, note that the gain is 20 dB. Because the loss
factor in this case is 0 dB, the scaling factor for the input signal is found by solving the
following equation for the multiplicative gain G from the gain in dB:
G = 10^(hr.Gain/20)
G =
10
The gain is 10. By scaling the input signal by a factor of ten and adding complex white
Gaussian noise with the appropriate variance, you produce an output equivalent to the
preceding call to phased.ReceiverPreamp.step (use the same seed for the random
number generation).
rng(1e3);
y1 = G*x + sqrt(noisepow/2)*(randn(size(x))+1j*randn(size(x)));
0
0
4-31
4 Waveforms, Transmitter, and Receiver
0
0
0
0
0
0
0
0
In a coherent on receive radar, the receiver corrects for the phase noise introduced at
the transmitter by using the record of those phase errors. You can input a record of the
transmitter phase errors to step when you set the PhaseNoiseInputPort property to
true.
To illustrate this, construct a rectangular pulse waveform with five pulses. The PRF is
10 kHz and the pulse width is 50 μs. The PRI is exactly two times the pulse width so the
transmitter alternates between active and inactive time intervals of the same duration.
For convenience, set the gains on both the transmitter and receiver to 0 dB and the peak
power on the transmitter to 1 watt.
Delay the output of the transmitter using delayseq to simulate the waveform arriving
at the receiver preamp when the transmitter is inactive and the receiver is active.
hrect = phased.RectangularWaveform('NumPulses',5);
htx = phased.Transmitter('CoherentOnTransmit',false,...
4-32
Receiver Preamp
'PhaseNoiseOutputPort',true,'Gain',0,'PeakPower',1,...
'SeedSource','Property','Seed',1000,'InUseOutputPort',true);
wf = step(hrect);
[txtoutput,txstatus,phnoise] = step(htx,wf);
txtoutput = delayseq(txtoutput,hrect.PulseWidth,...
hrect.SampleRate);
hrc = phased.ReceiverPreamp('Gain',0,...
'PhaseNoiseInputPort',true,'EnableInputPort',true);
y = step(hrc,txtoutput,~txstatus,phnoise);
subplot(2,1,1)
plot(real(txtoutput));
title('Delayed Transmitter Output with Phase Noise');
ylabel('Amplitude');
subplot(2,1,2)
plot(real(y));
xlabel('Samples'); ylabel('Amplitude');
title('Received Signal with Phase Correction');
4-33
4 Waveforms, Transmitter, and Receiver
Radar Equation
In this section...
“Radar Equation Theory” on page 4-34
“Link Budget Calculation Using the Radar Equation” on page 4-35
“Maximum Detectable Range for a Monostatic Radar” on page 4-36
“Output SNR at the Receiver in a Bistatic Radar” on page 4-37
PtGt Grl 2s
Pr =
( 4p ) 3 Rt2 Rr2 L
The equation for the power at the input to the receiver represents the signal term in the
signal-to-noise (SNR) ratio. To model the noise term, assume the thermal noise in the
receiver has a white noise power spectral density (PSD) given by:
4-34
Radar Equation
P( f ) = kT
where k is the Boltzmann constant and T is the effective noise temperature. The receiver
acts as a filter to shape the white noise PSD. Assume that the magnitude squared
receiver frequency response approximates a rectangular filter with bandwidth equal
to the reciprocal of the pulse duration, 1/τ. The total noise power at the output of the
receiver is:
kTFn
N=
t
The product of the effective noise temperature and the receiver noise factor is referred to
as the system temperature and is denoted by Ts, so that Ts = TFn .
Using the equation for the received signal power and the output noise power, the receiver
output SNR is:
Pr Ptt Gt Grl 2s
=
N (4p ) 3 kTs Rt2 Rr2 L
The preceding equations are implemented in the Phased Array System Toolbox by
the functions: radareqpow, radareqrng, and radareqsnr. These functions and
the equations on which they are based are valuable tools in radar system design and
analysis.
4-35
4 Waveforms, Transmitter, and Receiver
Use Albersheim's equation to determine the required SNR for the specified detection and
false-alarm probabilities.
Pd = 0.9;
Pfa = 1e-6;
NumPulses = 10;
SNR = albersheim(Pd,Pfa,10)
The required SNR is approximately 5 dB. Use the function radareqpow to determine the
required peak transmit power in watts.
4-36
Radar Equation
4-37
4-38
5
Beamforming
Conventional Beamforming
In this section...
“Uses for Beamformers” on page 5-2
“Support for Conventional Beamforming” on page 5-2
“Narrowband Phase Shift Beamformer with a ULA” on page 5-2
• Sensor array
• Signal propagation speed
• System operating frequency
• Beamforming direction
5-2
Conventional Beamforming
Simulate a test signal. For this example, use a simple rectangular pulse.
t = linspace(0,0.3,300)';
testsig = zeros(size(t));
testsig(201:205)= 1;
Assume the rectangular pulse is incident on the ULA from an angle of 30 degrees
azimuth and 0 degrees elevation. Use the collectPlaneWave method of the ULA object
to simulate reception of the pulse waveform from the specified angle.
angle_of_arrival = [30;0];
x = collectPlaneWave(hula,testsig,angle_of_arrival,fc);
x is a matrix with ten columns. Each column represents the received signal at one of the
array elements.
Corrupt the columns of x with complex-valued Gaussian noise. Reset the default random
number stream for reproducible results. Plot the magnitudes of the received pulses at the
first four elements of the ULA.
rng default
npower = 0.5;
x = x + sqrt(npower/2)*(randn(size(x))+1i*randn(size(x)));
subplot(221)
plot(t,abs(x(:,1))); title('Element 1 (magnitude)');
axis tight; ylabel('Magnitude');
subplot(222)
plot(t,abs(x(:,2))); title('Element 2 (magnitude)');
axis tight; ylabel('Magnitude');
subplot(223)
plot(t,abs(x(:,3))); title('Element 3 (magnitude)');
axis tight; xlabel('Seconds'); ylabel('Magnitude');
subplot(224)
plot(t,abs(x(:,4))); title('Element 4 (magnitude)');
axis tight; xlabel('Seconds'); ylabel('Magnitude');
5-3
5 Beamforming
hbf = phased.PhaseShiftBeamformer('SensorArray',hula,...
'OperatingFrequency',1e9,'Direction',angle_of_arrival,...
'WeightsOutputPort',true);
Apply the step method for the phase shift beamformer. The step method computes and
applies the correct weights for the specified angle. The phase-shifted outputs from the
ten array elements are then summed.
[y,w] = step(hbf,x);
Plot the magnitude of the output waveform along with the original waveform for
comparison.
figure;
subplot(211)
plot(t,abs(testsig)); axis tight;
title('Original Signal'); ylabel('Magnitude');
subplot(212)
plot(t,abs(y)); axis tight;
title('Received Signal with Beamforming');
ylabel('Magnitude'); xlabel('Seconds');
5-4
Conventional Beamforming
To examine the effect of the beamforming weights on the array response, plot the array
normalized power response both with—and without—the beamforming weights.
azang = -180:30:180;
figure;
subplot(211)
plotResponse(hula,fc,physconst('LightSpeed'));
set(gca,'xtick',azang);
title('Array Response without Beamforming Weights');
subplot(212)
plotResponse(hula,fc,physconst('LightSpeed'),'weights',w);
set(gca,'xtick',azang);
title('Array Response with Beamforming Weights');
5-5
5 Beamforming
Related Examples
• “Conventional and Adaptive Beamformers”
5-6
Adaptive Beamforming
Adaptive Beamforming
In this section...
“Benefits of Adaptive Beamforming” on page 5-7
“Support for Adaptive Beamforming” on page 5-7
“LCMV Beamformer” on page 5-7
LCMV Beamformer
This example uses code from the “Narrowband Phase Shift Beamformer with a ULA” on
page 5-2 example. Execute the code from that example before you run this example.
5-7
5 Beamforming
jammer is incident on the ULA at an angle of 120 degrees azimuth and 0 degrees
elevation.
hjammer = phased.BarrageJammer('ERP',10,'SamplesPerFrame',300);
jamsig = step(hjammer);
jammer_angle = [120;0];
jamsig = collectPlaneWave(hula,jamsig,jammer_angle,fc);
Add some low-level complex white Gaussian noise to simulate noise contributions not
directly associated with the jamming signal. Seed the random number generator for
reproducible results.
Implement the LCMV beamformer. Use the target-free data,jamsig, as training data.
Output the beamformer weights.
hstv = phased.SteeringVector('SensorArray',hula,...
'PropagationSpeed',physconst('LightSpeed'));
hLCMV = phased.LCMVBeamformer('DesiredResponse',1,...
'TrainingInputPort',true,'WeightsOutputPort',true);
hLCMV.Constraint = step(hstv,fc,angle_of_arrival);
hLCMV.DesiredResponse = 1;
[yLCMV,wLCMV] = step(hLCMV,rxsig,jamsig);
subplot(211)
plot(t,abs(yout)); axis tight;
title('Conventional Beamformer');
ylabel('Magnitude');
subplot(212);
plot(t,abs(yLCMV)); axis tight;
title('LCMV (Adaptive) Beamformer');
xlabel('Seconds'); ylabel('Magnitude');
5-8
Adaptive Beamforming
The adaptive beamformer significantly improves the SNR of the rectangular pulse at 0.2
s.
Plot the array normalized power response for the conventional and LCMV beamformers.
figure;
subplot(211)
plotResponse(hula,fc,physconst('LightSpeed'),'weights',w);
title('Array Response with Conventional Beamforming Weights');
subplot(212)
plotResponse(hula,fc,physconst('LightSpeed'),'weights',wLCMV);
title('Array Response with LCMV Beamforming Weights');
5-9
5 Beamforming
The LCMV beamforming weights place a null in the array response at the arrival angle
of the interference signal.
See Also
phased.FrostBeamformer | phased.LCMVBeamformer | phased.MVDRBeamformer
Related Examples
• “Conventional and Adaptive Beamformers”
5-10
Wideband Beamforming
Wideband Beamforming
In this section...
“Support for Wideband Beamforming” on page 5-11
“Time-Delay Beamforming” on page 5-11
“Visualization of Wideband Beamformer Performance” on page 5-13
Phased Array System Toolbox software provides conventional and adaptive wideband
beamformers. They include:
• phased.FrostBeamformer
• phased.SubbandPhaseShiftBeamformer
• phased.TimeDelayBeamformer
• phased.TimeDelayLCMVBeamformer
Time-Delay Beamforming
This example shows how to perform wideband conventional time-delay beamforming
with a microphone array.
Create an acoustic (pressure wave) chirp signal. The chirp signal has a bandwidth of 1
kHz and propagates at a speed of 340 m/s at sea level.
Collect the acoustic chirp with a ten-element ULA. Use omnidirectional microphone
elements spaced less than one-half the wavelength of the 50 kHz sampling frequency.
The chirp is incident on the ULA with an angle of 45 degrees azimuth and 0 degrees
elevation.
5-11
5 Beamforming
hmic = phased.OmnidirectionalMicrophoneElement(...
'FrequencyRange',[20 20e3]);
hula = phased.ULA('Element',hmic,'NumElements',10,...
'ElementSpacing',0.01);
hcol = phased.WidebandCollector('Sensor',hula,'SampleRate',5e4,...
'PropagationSpeed',c,'ModulatedInput',false);
sigang = [60; 0];
rsig = step(hcol,sig,sigang);
rsig = rsig+0.3*randn(size(rsig));
htbf = phased.TimeDelayBeamformer('SensorArray',hula,...
'SampleRate',5e4,'PropagationSpeed',c,'Direction',sigang);
y = step(htbf,rsig);
subplot(2,1,1);
plot(t(1:5e3),real(rsig(1:5e3,5)));
title('Signal (real part) at the 5th element of the ULA');
subplot(2,1,2);
plot(t(1:5e3),real(y(1:5e3)));
title('Signal (real part) with time-delay beamforming');
xlabel('Seconds');
5-12
Wideband Beamforming
c = 340;
freq = [1e3 2.75e3];
fc = 2e3;
numels = 11;
h = phased.CosineAntennaElement('FrequencyRange',freq);
ha = phased.ULA('NumElements',numels,...
'ElementSpacing',0.5*c/fc,'Element',h);
Plot the response pattern of the antenna element over a series of frequencies.
plotFreq = linspace(min(freq),max(freq),15);
figure;
plotResponse(h,plotFreq,'OverlayFreq',false);
The plot shows that the element pattern is constant over the entire bandwidth.
5-13
5 Beamforming
Plot the response pattern of the 11-element array over the same series of frequencies.
figure;
plotResponse(ha,plotFreq,c,'OverlayFreq',false);
Apply a subband phase shift beamformer to the array. The direction of interest is 30
degrees azimuth and 0 degrees elevation.
direction = [30;0];
numbands = 8;
hbf = phased.SubbandPhaseShiftBeamformer('SensorArray',ha,...
'Direction',direction,...
'OperatingFrequency',fc,'PropagationSpeed',c,...
'SampleRate',1e3,...
'WeightsOutputPort',true,'SubbandsOutputPort',true,...
'NumSubbands',numbands);
rx = ones(numbands,numels);
[y,w,centerFreq] = step(hbf,rx);
Plot the response pattern of the array again, using the weights and center frequencies
from the beamformer.
figure;
plotResponse(ha,centerFreq',c,'Weights',w,'OverlayFreq',false);
5-14
Wideband Beamforming
The plot shows the beamformed pattern at the center frequency of each subband.
centerFreq = fftshift(centerFreq);
w = fftshift(w,2);
idx = [1 5 8];
figure;
plotResponse(ha,centerFreq(idx)',c,'Weights',w(:,idx));
legend('Location','South')
5-15
5 Beamforming
This plot shows that the main beam direction remains constant, but the beam width
decreases with frequency.
5-16
6
Construct a ULA consisting of ten elements. Assume the carrier frequency of the
incoming narrowband sources is 1 GHz.
fc = 1e9;
lambda = physconst('LightSpeed')/fc;
hula = phased.ULA('NumElements',10,'ElementSpacing',lambda/2);
hula.Element.FrequencyRange = [8e8 1.2e9];
Assume that there is a wavefield incident on the ULA consisting of two linear FM pulses.
The DOAs of the two sources are 30 degrees azimuth and 60 degrees azimuth. Both
sources have elevation angles of zero degrees.
hwav = phased.LinearFMWaveform('SweepBandwidth',1e5,...
'PulseWidth',5e-6,'OutputFormat','Pulses','NumPulses',1);
sig1 = step(hwav);
sig2 = sig1;
ang1 = [30; 0];
ang2 = [60;0];
arraysig = collectPlaneWave(hula,[sig1 sig2],[ang1 ang2],fc);
rng default
npower = 0.01;
noise = sqrt(npower/2)*...
(randn(size(arraysig))+1i*randn(size(arraysig)));
rxsig = arraysig+noise;
Implement a beamscan DOA estimator. Output the DOA estimates, and plot the spatial
spectrum.
hbeam = phased.BeamscanEstimator('SensorArray',hula,...
'OperatingFrequency',fc,'ScanAngles',-90:90,...
'DOAOutputPort',true,'NumSignals',2);
[y,sigang] = step(hbeam,rxsig);
plotSpectrum(hbeam);
6-2
Beamscan Direction-of-Arrival Estimation
Related Examples
• “Super-resolution DOA Estimation” on page 6-4
• Direction of Arrival Estimation with Beamscan and MVDR
6-3
6 Direction-of-Arrival (DOA) Estimation
Plot the array response of the ULA used in the “Beamscan Direction-of-Arrival
Estimation” on page 6-2 example. Zoom in on the main lobe.
fc = 1e9;
lambda = physconst('LightSpeed')/fc;
hula = phased.ULA('NumElements',10,'ElementSpacing',lambda/2);
hula.Element.FrequencyRange = [8e8 1.2e9];
plotResponse(hula,fc,physconst('LightSpeed'));
axis([-25 25 -30 0]);
Estimate the directions of arrival using the beamscan estimator. Because both DOAs fall
inside the main lobe of the array response, the beamscan DOA estimator cannot resolve
them as separate sources.
6-4
Super-resolution DOA Estimation
hbeam = phased.BeamscanEstimator('SensorArray',hula,...
'OperatingFrequency',fc,'ScanAngles',-90:90,...
'DOAOutputPort',true,'NumSignals',2);
[~,sigang] = step(hbeam,rxsig);
figure;
plotSpectrum(hbeam);
hroot = phased.RootMUSICEstimator('SensorArray',hula,...
'OperatingFrequency',fc,'NumSignalsSource','Property',...
'NumSignals',2,'ForwardBackwardAveraging',true);
doa_est = step(hroot,rxsig)
doa_est =
40.0091 30.0048
See Also
phased.RootMUSICEstimator
Related Examples
• “Beamscan Direction-of-Arrival Estimation” on page 6-2
6-5
6 Direction-of-Arrival (DOA) Estimation
6-6
7
Angle-Doppler Response
In this section...
“Benefits of Visualizing Angle-Doppler Response” on page 7-2
“Angle-Doppler Response of a Stationary Target at a Stationary Array” on page 7-2
“Angle-Doppler Response of a Stationary Target Return at a Moving Array” on page
7-4
The array operates at 4 GHz with elements spaced at one-half the operating wavelength.
The array transmits a rectangular pulse 2 microseconds in duration with a pulse
repetition frequency (PRF) of 5 kHz.
Construct the objects needed to simulate the target response at the array.
hant = phased.IsotropicAntennaElement...
('FrequencyRange',[8e8 5e9],'BackBaffled',true);
lambda = physconst('LightSpeed')/4e9;
hula = phased.ULA(6,'Element',hant,'ElementSpacing',lambda/2);
hwav = phased.RectangularWaveform('PulseWidth',2e-006,...
'PRF',5e3,'SampleRate',1e6,'NumPulses',1);
7-2
Angle-Doppler Response
hrad = phased.Radiator('Sensor',hula,...
'PropagationSpeed',physconst('LightSpeed'),...
'OperatingFrequency',4e9);
hcol = phased.Collector('Sensor',hula,...
'PropagationSpeed',physconst('LightSpeed'),...
'OperatingFrequency',4e9);
htxplat = phased.Platform('InitialPosition',[0;0;0],...
'Velocity',[0;0;0]);
htgt = phased.RadarTarget('MeanRCS',1,'Model','nonfluctuating');
htgtplat = phased.Platform('InitialPosition',[5e3; 5e3; 0],...
'Velocity',[0;0;0]);
hspace = phased.FreeSpace('OperatingFrequency',4e9,...
'TwoWayPropagation',false,'SampleRate',1e6);
hrx = phased.ReceiverPreamp('NoiseFigure',0,...
'EnableInputPort',true,'SampleRate',1e6,'Gain',40);
htx = phased.Transmitter('PeakPower',1e4,...
'InUseOutputPort',true,'Gain',40);
Propagate ten rectangular pulses to and from the target, and collect the responses at the
array.
PRF = 5e3;
NumPulses = 10;
wav = step(hwav);
tgtloc = htgtplat.InitialPosition;
txloc = htxplat.InitialPosition;
M = hwav.SampleRate*1/PRF;
N = hula.NumElements;
rxsig = zeros(M,N,NumPulses);
for n = 1:NumPulses
% get angle to target
[~,tgtang] = rangeangle(tgtloc,txloc);
% transmit pulse
[txsig,txstatus] = step(htx,wav);
% radiate pulse
txsig = step(hrad,txsig,tgtang);
% propagate pulse to target
txsig = step(hspace,txsig,txloc,tgtloc,[0;0;0],[0;0;0]);
% reflect pulse off stationary target
txsig = step(htgt,txsig);
% propagate pulse to array
txsig = step(hspace,txsig,tgtloc,txloc,[0;0;0],[0;0;0]);
% collect pulse
rxsig(:,:,n) = step(hcol,txsig,tgtang);
7-3
7 Space-Time Adaptive Processing (STAP)
% receive pulse
rxsig(:,:,n) = step(hrx,rxsig(:,:,n),~txstatus);
end
Determine and plot the angle-Doppler response. Place the string +Target at the
expected azimuth angle and Doppler frequency.
tgtdoppler = 0;
tgtLocation = global2localcoord(tgtloc,'rs',txloc);
tgtazang = tgtLocation(1);
tgtelang = tgtLocation(2);
tgtrng = tgtLocation(3);
tgtcell = val2ind(tgtrng,...
physconst('LightSpeed')/(2*hwav.SampleRate));
snapshot = shiftdim(rxsig(tgtcell,:,:)); % Remove singleton dim
hadresp = phased.AngleDopplerResponse('SensorArray',hula,...
'OperatingFrequency',4e9, ...
'PropagationSpeed',physconst('LightSpeed'),...
'PRF',PRF, 'ElevationAngle',tgtelang);
plotResponse(hadresp,snapshot);
text(tgtazang,tgtdoppler,'+Target');
As expected, the angle-Doppler response shows the greatest response at zero Doppler and
45 degrees azimuth.
7-4
Angle-Doppler Response
slow-moving targets because the motion-induced Doppler shift and spread of the clutter
returns obscure the Doppler shifts of such targets.
Transmit ten rectangular pulses toward the target as the ULA is moving. Then, collect
the received echoes.
PRF = 5e3;
NumPulses = 10;
wav = step(hwav);
tgtloc = htgtplat.InitialPosition;
7-5
7 Space-Time Adaptive Processing (STAP)
M = hwav.SampleRate*1/PRF;
N = hula.NumElements;
rxsig = zeros(M,N,NumPulses);
fasttime = unigrid(0,1/hwav.SampleRate,1/PRF,'[)');
rangebins = (physconst('LightSpeed')*fasttime)/2;
for n = 1:NumPulses
% move transmitter
[txloc,txvel] = step(htxplat,1/PRF);
% get angle to target
[~,tgtang] = rangeangle(tgtloc,txloc);
% transmit pulse
[txsig,txstatus] = step(htx,wav);
% radiate pulse
txsig = step(hrad,txsig,tgtang);
% propagate pulse to target
txsig = step(hspace,txsig,txloc,tgtloc,txvel,tgtvel);
% reflect pulse off stationary target
txsig = step(htgt,txsig);
% propagate pulse to array
txsig = step(hspace,txsig,tgtloc,txloc,tgtvel,txvel);
% collect pulse
rxsig(:,:,n) = step(hcol,txsig,tgtang);
% receive pulse
rxsig(:,:,n) = step(hrx,rxsig(:,:,n),~txstatus);
end
Calculate the target angles and range with respect to the ULA. Then, calculate the
Doppler shift induced by the motion of the phased array.
sp = radialspeed(tgtloc,tgtvel,txloc,txvel);
tgtdoppler = 2*speed2dop(sp,lambda);
tgtLocation = global2localcoord(tgtloc,'rs',txloc);
tgtazang = tgtLocation(1);
tgtelang = tgtLocation(2);
tgtrng = tgtLocation(3);
The two-way Doppler shift is approximately 1626 Hz. The azimuth angle is 45 degrees
and is identical to the stationary ULA example.
7-6
Angle-Doppler Response
hadresp = phased.AngleDopplerResponse('SensorArray',hula,...
'OperatingFrequency',4e9, ...
'PropagationSpeed',physconst('LightSpeed'),...
'PRF',PRF, 'ElevationAngle',tgtelang);
plotResponse(hadresp,snapshot);
text(tgtazang,tgtdoppler,'+Target');
The angle-Doppler response shows the greatest response at 45 degrees azimuth and the
expected Doppler shift.
7-7
7 Space-Time Adaptive Processing (STAP)
The DPCA pulse canceller is applicable when both these conditions are true:
vT = d / 2
where:
7-8
Displaced Phase Center Antenna (DPCA) Pulse Canceller
radar emits ten rectangular pulses two microseconds in duration with a PRF of 5 kHz.
The platform moves along the array axis with a speed equal to one-half the product of
the element spacing and the PRF. As a result, the condition in Equation 7-1 applies. The
target has a nonfluctuating RCS of 1 square meter and moves with a constant velocity
vector of [15;15;0]. The following MATLAB code constructs the required System
objects to simulate the signal received by the ULA.
PRF = 5e3;
fc = 4e9; fs = 1e6;
c = physconst('LightSpeed');
hant = phased.IsotropicAntennaElement...
('FrequencyRange',[8e8 5e9],'BackBaffled',true);
lambda = c/fc;
hula = phased.ULA(6,'Element',hant,'ElementSpacing',lambda/2);
hwav = phased.RectangularWaveform('PulseWidth',2e-6,...
'PRF',PRF,'SampleRate',fs,'NumPulses',1);
hrad = phased.Radiator('Sensor',hula,...
'PropagationSpeed',c,...
'OperatingFrequency',fc);
hcol = phased.Collector('Sensor',hula,...
'PropagationSpeed',c,...
'OperatingFrequency',fc);
vy = (hula.ElementSpacing * PRF)/2;
htxplat = phased.Platform('InitialPosition',[0;0;3e3],...
'Velocity',[0;vy;0]);
hclutter = phased.ConstantGammaClutter('Sensor',hula,...
'PropagationSpeed',hrad.PropagationSpeed,...
'OperatingFrequency',hrad.OperatingFrequency,...
'SampleRate',fs,...
'TransmitSignalInputPort',true,...
'PRF',PRF,...
'Gamma',surfacegamma('woods',hrad.OperatingFrequency),...
'EarthModel','Flat',...
'BroadsideDepressionAngle',0,...
'MaximumRange',hrad.PropagationSpeed/(2*PRF),...
'PlatformHeight',htxplat.InitialPosition(3),...
'PlatformSpeed',norm(htxplat.Velocity),...
'PlatformDirection',[90;0]);
htgt = phased.RadarTarget('MeanRCS',1,...
'Model','Nonfluctuating','OperatingFrequency',fc);
htgtplat = phased.Platform('InitialPosition',[5e3; 5e3; 0],...
'Velocity',[15;15;0]);
hspace = phased.FreeSpace('OperatingFrequency',fc,...
'TwoWayPropagation',false,'SampleRate',fs);
hrx = phased.ReceiverPreamp('NoiseFigure',0,...
'EnableInputPort',true,'SampleRate',fs,'Gain',40);
htx = phased.Transmitter('PeakPower',1e4,...
'InUseOutputPort',true,'Gain',40);
Propagate the ten rectangular pulses to and from the target, and collect the responses at
the array. Also, compute clutter echoes using the constant gamma model with a gamma
value corresponding to wooded terrain.
7-9
7 Space-Time Adaptive Processing (STAP)
NumPulses = 10;
wav = step(hwav);
M = fs/PRF;
N = hula.NumElements;
rxsig = zeros(M,N,NumPulses);
csig = zeros(M,N,NumPulses);
fasttime = unigrid(0,1/fs,1/PRF,'[)');
rangebins = (c * fasttime)/2;
hclutter.SeedSource = 'Property';
hclutter.Seed = 5;
for n = 1:NumPulses
[txloc,txvel] = step(htxplat,1/PRF); % move transmitter
[tgtloc,tgtvel] = step(htgtplat,1/PRF); % move target
[~,tgtang] = rangeangle(tgtloc,txloc); % get angle to target
[txsig1,txstatus] = step(htx,wav); % transmit pulse
csig(:,:,n) = step(hclutter,txsig1(abs(txsig1)>0)); % collect clutter
txsig = step(hrad,txsig1,tgtang); % radiate pulse
txsig = step(hspace,txsig,txloc,tgtloc,...
txvel,tgtvel); % propagate to target
txsig = step(htgt,txsig); % reflect off target
txsig = step(hspace,txsig,tgtloc,txloc,...
tgtvel,txvel); % propagate to array
rxsig(:,:,n) = step(hcol,txsig,tgtang); % collect pulse
rxsig(:,:,n) = step(hrx,rxsig(:,:,n) + csig(:,:,n),...
~txstatus); % receive pulse plus clutter return
end
Determine the target's range, range gate, and two-way Doppler shift.
sp = radialspeed(tgtloc,tgtvel,txloc,txvel);
tgtdoppler = 2*speed2dop(sp,lambda);
tgtLocation = global2localcoord(tgtloc,'rs',txloc);
tgtazang = tgtLocation(1);
tgtelang = tgtLocation(2);
tgtrng = tgtLocation(3);
tgtcell = val2ind(tgtrng,c/(2 * fs));
Use noncoherent pulse integration to visualize the signal received by the ULA for the
first of the ten pulses. Mark the target's range gate with a vertical dashed line.
firstpulse = pulsint(rxsig(:,:,1),'noncoherent');
figure;
plot([tgtrng tgtrng],[0 0.1],'-.',rangebins,firstpulse);
title('Noncoherent Integration of 1st Pulse at the ULA');
xlabel('Range (m)'); ylabel('Magnitude');
7-10
Displaced Phase Center Antenna (DPCA) Pulse Canceller
The large-magnitude clutter returns obscure the presence of the target. Apply the DPCA
pulse canceller to reject the clutter.
hstap = phased.DPCACanceller('SensorArray',hula,'PRF',PRF,...
'PropagationSpeed',c,...
'OperatingFrequency',fc,...
'Direction',[0;0],'Doppler',tgtdoppler,...
'WeightsOutputPort',true);
[y,w] = step(hstap,rxsig,tgtcell);
Plot the result of applying the DPCA pulse canceller. Mark the target range gate with a
vertical dashed line.
figure;
plot([tgtrng,tgtrng],[0 3.5e-5],'-.',rangebins,abs(y));
title('DPCA Canceller Output');
xlabel('Range (m)'), ylabel('Magnitude');
7-11
7 Space-Time Adaptive Processing (STAP)
The DPCA pulse canceller has significantly rejected the clutter. As a result, the target is
visible at the expected range gate.
7-12
Adaptive Displaced Phase Center Antenna Pulse Canceller
• Jamming and other interference effects are substantial. The DPCA pulse canceller
is susceptible to interference because the DPCA pulse canceller does not use the
received data.
• The sample matrix inversion (SMI) algorithm is inapplicable because of
computational expense or a rapidly changing environment.
• The number of training cells. The algorithm uses training cells to estimate the
interference. In general, a larger number of training cells leads to a better estimate of
interference.
• The number of guard cells close to the target cells. The algorithm recognizes guard
cells to prevent target returns from contaminating the estimate of the interference.
To repeat the scenario for convenience, the airborne radar platform is a six-element
ULA operating at 4 GHz. The array elements are spaced at one-half the wavelength of
the 4 GHz carrier frequency. The radar emits ten rectangular pulses two μs in duration
with a PRF of 5 kHz. The platform is moving along the array axis with a speed equal
7-13
7 Space-Time Adaptive Processing (STAP)
to one-half the product of the element spacing and the PRF. As a result, the condition
in Equation 7-1 applies. The target has a nonfluctuating RCS of 1 square meter and is
moving with a constant velocity vector of [15;15;0].
The following commands construct the required System objects to simulate the scenario.
PRF = 5e3;
fc = 4e9; fs = 1e6;
c = physconst('LightSpeed');
hant = phased.IsotropicAntennaElement...
('FrequencyRange',[8e8 5e9],'BackBaffled',true);
lambda = c/fc;
hula = phased.ULA(6,'Element',hant,'ElementSpacing',lambda/2);
hwav = phased.RectangularWaveform('PulseWidth', 2e-6,...
'PRF',PRF,'SampleRate',fs,'NumPulses',1);
hrad = phased.Radiator('Sensor',hula,...
'PropagationSpeed',c,...
'OperatingFrequency',fc);
hcol = phased.Collector('Sensor',hula,...
'PropagationSpeed',c,...
'OperatingFrequency',fc);
vy = (hula.ElementSpacing * PRF)/2;
htxplat = phased.Platform('InitialPosition',[0;0;3e3],...
'Velocity',[0;vy;0]);
hclutter = phased.ConstantGammaClutter('Sensor',hula,...
'PropagationSpeed',hrad.PropagationSpeed,...
'OperatingFrequency',hrad.OperatingFrequency,...
'SampleRate',fs,...
'TransmitSignalInputPort',true,...
'PRF',PRF,...
'Gamma',surfacegamma('woods',hrad.OperatingFrequency),...
'EarthModel','Flat',...
'BroadsideDepressionAngle',0,...
'MaximumRange',hrad.PropagationSpeed/(2*PRF),...
'PlatformHeight',htxplat.InitialPosition(3),...
'PlatformSpeed',norm(htxplat.Velocity),...
'PlatformDirection',[90;0]);
htgt = phased.RadarTarget('MeanRCS',1,...
'Model','Nonfluctuating','OperatingFrequency',fc);
htgtplat = phased.Platform('InitialPosition',[5e3; 5e3; 0],...
'Velocity',[15;15;0]);
hjammer = phased.BarrageJammer('ERP',1e3,'SamplesPerFrame',200);
hjammerplat = phased.Platform(...
'InitialPosition',[3.5e3; 1e3; 0],'Velocity',[0;0;0]);
hspace = phased.FreeSpace('OperatingFrequency',fc,...
'TwoWayPropagation',false,'SampleRate',fs);
hrx = phased.ReceiverPreamp('NoiseFigure',0,...
'EnableInputPort',true,'SampleRate',fs,'Gain',40);
htx = phased.Transmitter('PeakPower',1e4,...
'InUseOutputPort',true,'Gain',40);
Propagate the ten rectangular pulses to and from the target and collect the responses at
the array. Compute clutter echoes using the constant gamma model with a gamma value
7-14
Adaptive Displaced Phase Center Antenna Pulse Canceller
corresponding to wooded terrain. Also, propagate the jamming signal from the jammer
location to the airborne ULA.
NumPulses = 10;
wav = step(hwav);
M = fs/PRF;
N = hula.NumElements;
rxsig = zeros(M,N,NumPulses);
csig = zeros(M,N,NumPulses);
jsig = zeros(M,N,NumPulses);
fasttime = unigrid(0,1/fs,1/PRF,'[)');
rangebins = (c * fasttime)/2;
hclutter.SeedSource = 'Property';
hclutter.Seed = 40543;
hjammer.SeedSource = 'Property';
hjammer.Seed = 96703;
hrx.SeedSource = 'Property';
hrx.Seed = 56113;
jamloc = hjammerplat.InitialPosition;
for n = 1:NumPulses
[txloc,txvel] = step(htxplat,1/PRF); % move transmitter
[tgtloc,tgtvel] = step(htgtplat,1/PRF); % move target
[~,tgtang] = rangeangle(tgtloc,txloc); % get angle to target
[txsig,txstatus] = step(htx,wav); % transmit pulse
csig(:,:,n) = step(hclutter,txsig(abs(txsig)>0)); % collect clutter
rxsig(:,:,n) = step(hrx,...
rxsig(:,:,n) + csig(:,:,n) + jsig(:,:,n),...
~txstatus); % receive pulse plus clutter return plus jammer signal
end
Determine the target's range, range gate, and two-way Doppler shift.
sp = radialspeed(tgtloc, htgtplat.Velocity, ...
txloc, htxplat.Velocity);
tgtdoppler = 2*speed2dop(sp,lambda);
tgtLocation = global2localcoord(tgtloc,'rs',txloc);
tgtazang = tgtLocation(1);
tgtelang = tgtLocation(2);
tgtrng = tgtLocation(3);
7-15
7 Space-Time Adaptive Processing (STAP)
Process the array responses using the nonadaptive DPCA pulse canceller. To do so,
construct the DPCA object, and apply it to the received signals.
hstap = phased.DPCACanceller('SensorArray',hula,'PRF',PRF,...
'PropagationSpeed',c,...
'OperatingFrequency',fc,...
'Direction',[0;0],'Doppler',tgtdoppler,...
'WeightsOutputPort',true);
[y,w] = step(hstap,rxsig,tgtcell);
Plot the DPCA result with the target range marked by a vertical dashed line. Notice how
the presence of the interference signal has obscured the target.
figure;
plot([tgtrng,tgtrng],[0 7e-2],'-.',rangebins,abs(y));
axis tight;
xlabel('Range (m)'), ylabel('Magnitude');
title('DPCA Canceller Output with Jamming')
Apply the adaptive DPCA pulse canceller. Use 100 training cells and 4 guard cells, two
on each side of the target range gate.
hstap = phased.ADPCACanceller('SensorArray',hula,'PRF',PRF,...
'PropagationSpeed',c,...
'OperatingFrequency',fc,...
'Direction',[0;0],'Doppler',tgtdoppler,...
'WeightsOutputPort',true,'NumGuardCells',4,...
'NumTrainingCells',100);
[y_adpca,w_adpca] = step(hstap,rxsig,tgtcell);
Plot the result with the target range marked by a vertical dashed line. Notice how the
adaptive DPCA pulse canceller enables you to detect the target in the presence of the
jamming signal.
7-16
Adaptive Displaced Phase Center Antenna Pulse Canceller
figure;
plot([tgtrng,tgtrng],[0 4e-7],'-.',rangebins,abs(y_adpca));
axis tight;
title('ADPCA Canceller Output with Jamming');
xlabel('Range (m)'), ylabel('Magnitude');
Examine the angle-Doppler response. Notice the presence of the clutter ridge in the
angle-Doppler plane and the null at the jammer’s broadside angle for all Doppler
frequencies.
hadresp = phased.AngleDopplerResponse('SensorArray',hula,...
'OperatingFrequency',fc,...
'PropagationSpeed',c,...
'PRF',PRF,'ElevationAngle',tgtelang);
figure;
plotResponse(hadresp,w_adpca);
title('Angle-Doppler Response with ADPCA Pulse Cancellation');
text(az2broadside(jamang(1),jamang(2)) + 10,...
0,'\leftarrow Interference Null')
7-17
7 Space-Time Adaptive Processing (STAP)
• The number of training cells. The algorithm uses training cells to estimate the
interference. In general, a larger number of training cells leads to a better estimate of
interference.
• The number of guard cells close to the target cells. The algorithm recognizes guard
cells to prevent target returns from contaminating the estimate of the interference.
To repeat the scenario for convenience, the airborne radar platform is a six-element ULA
operating at 4 GHz. The array elements are spaced at one-half the wavelength of the 4
7-18
Sample Matrix Inversion (SMI) Beamformer
GHz carrier frequency. The radar emits ten rectangular pulses two μs in duration with
a PRF of 5 kHz. The platform is moving along the array axis with a speed equal to one-
half the product of the element spacing and the PRF. The target has a nonfluctuating
RCS of 1 square meter and is moving with a constant velocity vector of [15;15;0]. A
stationary broadband barrage jammer is located at [3.5e3; 1e3; 0]. The jammer has
an effective radiated power of 1 kw.
The following commands construct the required System objects to simulate the scenario.
PRF = 5e3;
fc = 4e9; fs = 1e6;
c = physconst('LightSpeed');
hant = phased.IsotropicAntennaElement...
('FrequencyRange',[8e8 5e9],'BackBaffled',true);
lambda = c/fc;
hula = phased.ULA(6,'Element',hant,'ElementSpacing',lambda/2);
hwav = phased.RectangularWaveform('PulseWidth', 2e-6,...
'PRF',PRF,'SampleRate',fs,'NumPulses',1);
hrad = phased.Radiator('Sensor',hula,...
'PropagationSpeed',c,...
'OperatingFrequency',fc);
hcol = phased.Collector('Sensor',hula,...
'PropagationSpeed',c,...
'OperatingFrequency',fc);
vy = (hula.ElementSpacing * PRF)/2;
htxplat = phased.Platform('InitialPosition',[0;0;3e3],...
'Velocity',[0;vy;0]);
hclutter = phased.ConstantGammaClutter('Sensor',hula,...
'PropagationSpeed',hrad.PropagationSpeed,...
'OperatingFrequency',hrad.OperatingFrequency,...
'SampleRate',fs,...
'TransmitSignalInputPort',true,...
'PRF',PRF,...
'Gamma',surfacegamma('woods',hrad.OperatingFrequency),...
'EarthModel','Flat',...
'BroadsideDepressionAngle',0,...
'MaximumRange',hrad.PropagationSpeed/(2*PRF),...
'PlatformHeight',htxplat.InitialPosition(3),...
'PlatformSpeed',norm(htxplat.Velocity),...
'PlatformDirection',[90;0]);
htgt = phased.RadarTarget('MeanRCS',1,...
'Model','Nonfluctuating','OperatingFrequency',fc);
htgtplat = phased.Platform('InitialPosition',[5e3; 5e3; 0],...
'Velocity',[15;15;0]);
hjammer = phased.BarrageJammer('ERP',1e3,'SamplesPerFrame',200);
hjammerplat = phased.Platform(...
'InitialPosition',[3.5e3; 1e3; 0],'Velocity',[0;0;0]);
hspace = phased.FreeSpace('OperatingFrequency',fc,...
'TwoWayPropagation',false,'SampleRate',fs);
hrx = phased.ReceiverPreamp('NoiseFigure',0,...
'EnableInputPort',true,'SampleRate',fs,'Gain',40);
htx = phased.Transmitter('PeakPower',1e4,...
'InUseOutputPort',true,'Gain',40);
7-19
7 Space-Time Adaptive Processing (STAP)
Propagate the ten rectangular pulses to and from the target and collect the responses at
the array. Compute clutter echoes using the constant gamma model with a gamma value
corresponding to wooded terrain. Also, propagate the jamming signal from the jammer
location to the airborne ULA.
NumPulses = 10;
wav = step(hwav);
M = fs/PRF;
N = hula.NumElements;
rxsig = zeros(M,N,NumPulses);
csig = zeros(M,N,NumPulses);
jsig = zeros(M,N,NumPulses);
fasttime = unigrid(0,1/fs,1/PRF,'[)');
rangebins = (c * fasttime)/2;
hclutter.SeedSource = 'Property';
hclutter.Seed = 40543;
hjammer.SeedSource = 'Property';
hjammer.Seed = 96703;
hrx.SeedSource = 'Property';
hrx.Seed = 56113;
jamloc = hjammerplat.InitialPosition;
for n = 1:NumPulses
[txloc,txvel] = step(htxplat,1/PRF); % move transmitter
[tgtloc,tgtvel] = step(htgtplat,1/PRF); % move target
[~,tgtang] = rangeangle(tgtloc,txloc); % get angle to target
[txsig,txstatus] = step(htx,wav); % transmit pulse
csig(:,:,n) = step(hclutter,txsig(abs(txsig)>0)); % collect clutter
rxsig(:,:,n) = step(hrx,...
rxsig(:,:,n) + csig(:,:,n) + jsig(:,:,n),...
~txstatus); % receive pulse plus clutter return plus jammer signal
end
Determine the target's range, range gate, and two-way Doppler shift.
sp = radialspeed(tgtloc, htgtplat.Velocity, ...
txloc, htxplat.Velocity);
tgtdoppler = 2*speed2dop(sp,lambda);
tgtLocation = global2localcoord(tgtloc,'rs',txloc);
7-20
Sample Matrix Inversion (SMI) Beamformer
tgtazang = tgtLocation(1);
tgtelang = tgtLocation(2);
tgtrng = tgtLocation(3);
tgtcell = val2ind(tgtrng,c/(2 * fs));
Construct an SMI beamformer object. Use 100 training cells, 50 on each side of the target
range gate. Use four guard cells, two range gates in front of the target cell and two range
gates beyond the target cell. Obtain the beamformer response and weights.
tgtang = [tgtazang; tgtelang];
hstap = phased.STAPSMIBeamformer('SensorArray',hula,...
'PRF',PRF,'PropagationSpeed',c,...
'OperatingFrequency',fc,...
'Direction',tgtang,'Doppler',tgtdoppler,...
'WeightsOutputPort',true,...
'NumGuardCells',4,'NumTrainingCells',100);
[y,weights] = step(hstap,rxsig,tgtcell);
7-21
7 Space-Time Adaptive Processing (STAP)
7-22
8
Detection
When you choose the NP criterion, you can use npwgnthresh to determine the threshold
for the detection of deterministic signals in white Gaussian noise. The optimal decision
rule derives from a likelihood ratio test (LRT). An LRT chooses between the null and
alternative hypotheses based on a ratio of conditional probabilities.
For details about the statistical assumptions the npwgnthresh function makes, see the
reference page for that function.
8-2
Neyman-Pearson Hypothesis Testing
Determine the required signal-to-noise (SNR) in decibels for the NP detector when the
maximum tolerable false-alarm probability is 10–3.
Pfa = 1e-3;
T = npwgnthresh(Pfa,1,'real');
variance = 1;
threshold = sqrt(variance * db2pow(T));
Verify empirically that the threshold results in the desired false-alarm probability under
the null hypothesis. To do so, generate 1 million samples of a Gaussian random variable,
and determine the proportion of samples that exceed the threshold.
rng default
N = 1e6;
x = sqrt(variance) * randn(N,1);
falsealarmrate = sum(x > threshold)/N
falsealarmrate =
9.9500e-04
Plot the first 10,000 samples and a line showing the threshold.
x1 = x(1:1e4);
plot(x1)
line([1 length(x1)],[threshold threshold],'Color','red');
xlabel('Sample'); ylabel('Value');
8-3
8 Detection
The red horizontal line in the plot indicates the threshold. You can see that few sample
values exceed the threshold. This result is expected because of the small false-alarm
probability.
Determine the required SNR for the NP detector when the maximum tolerable false-
alarm probability is 10–3.
Pfa = 1e-3;
T = npwgnthresh(Pfa,2,'real');
8-4
Neyman-Pearson Hypothesis Testing
threshold = sqrt(variance*db2pow(T));
falsealarmrate = sum(intpuls > threshold)/N
falsealarmrate =
9.8900e-04
Determine the required SNR for the NP detector in a coherent detection scheme with one
sample. Use a maximum tolerable false-alarm probability of 10–3.
Pfa = 1e-3;
T = npwgnthresh(Pfa,1,'coherent');
Test that this threshold empirically results in the correct false-alarm rate The sufficient
statistic in the complex-valued case is the real part of received sample.
rng default
variance = 1;
N = 1e6;
x = sqrt(variance/2)*(randn(N,1)+1j*randn(N,1));
threshold = sqrt(variance*db2pow(T));
falsealarmrate = sum(real(x)>threshold)/length(x)
falsealarmrate =
9.9500e-04
8-5
8 Detection
If you are interested in examining the effect of varying the false-alarm probability on the
probability of detection for a fixed SNR, you can use rocsnr.
For example, the threshold SNR for the Neyman-Pearson detector of a single sample in
real-valued Gaussian noise is approximately 13.5 dB. Use rocsnr to demonstrate how
the probability of detection varies as a function of the false-alarm rate at that SNR.
T = npwgnthresh(1e-6,1,'real');
rocsnr(T,'SignalType','real')
The ROC curve enables you to easily read off the probability of detection for a given false-
alarm rate.
You can use rocsnr to examine detector performance for different received signal types
at a fixed SNR.
SNR = 13.54;
[Pd_real,Pfa_real] = rocsnr(SNR,'SignalType','real',...
'MinPfa',1e-8);
8-6
Receiver Operating Characteristic (ROC) Curves
[Pd_coh,Pfa_coh] = rocsnr(SNR,...
'SignalType','NonfluctuatingCoherent',...
'MinPfa',1e-8);
[Pd_noncoh,Pfa_noncoh] = rocsnr(SNR,'SignalType',...
'NonfluctuatingNoncoherent','MinPfa',1e-8);
figure;
semilogx(Pfa_real,Pd_real); hold on; grid on;
semilogx(Pfa_coh,Pd_coh,'r');
semilogx(Pfa_noncoh,Pd_noncoh,'k');
xlabel('False-Alarm Probability');
ylabel('Probability of Detection');
legend('Real','Coherent','Noncoherent','location','southeast');
title('ROC Curve Comparison for Nonfluctuating RCS Target');
The ROC curves clearly demonstrate the superior probability of detection performance
for coherent and noncoherent detectors over the real-valued case.
The rocsnr function accepts an SNR vector input enabling you to quickly examine a
number of ROC curves.
SNRs = (6:2:12);
figure;
rocsnr(SNRs,'SignalType','NonfluctuatingNoncoherent');
8-7
8 Detection
The graph shows that—as the SNR increases—the supports of the probability
distributions under the null and alternative hypotheses become more disjoint. Therefore,
for a given false-alarm probability, the probability of detection increases.
You can examine the probability of detection as a function of SNR for a fixed false-alarm
probability with rocpfa.
To obtain ROC curves for a Swerling I target model at false-alarm probabilities of [1e-6
1e-4 1e-2 1e-1], enter:
8-8
Receiver Operating Characteristic (ROC) Curves
Use rocpfa to examine the effect of SNR on the probability of detection for a detector
using noncoherent integration with a false-alarm probability of 1e-4. Assume the target
has a nonfluctuating RCS and that you are integrating over 5 pulses.
[Pd,SNR] = rocpfa(1e-4,...
'SignalType','NonfluctuatingNoncoherent',...
'NumPulses',5);
figure;
plot(SNR,Pd); xlabel('SNR (dB)');
ylabel('Probability of Detection'); grid on;
title('Nonfluctuating Noncoherent Detector (5 Pulses)');
8-9
8 Detection
Related Examples
• Detector Performance Analysis using ROC Curves
8-10
Matched Filtering
Matched Filtering
In this section...
“Reasons for Using Matched Filtering” on page 8-11
“Support for Matched Filtering” on page 8-11
“Matched Filtering of Linear FM Waveform” on page 8-11
“Matched Filtering to Improve SNR for Target Detection” on page 8-13
8-11
8 Detection
'SampleRate',1e6,'OutputFormat','Pulses','NumPulses',1,...
'SweepBandwidth',1e5);
w = getMatchedFilter(hwav);
8-12
Matched Filtering
Place an isotropic antenna element at the global origin [0;0;0]. Then, place a
target with a nonfluctuating RCS of 1 square meter at [5000;5000;10], which is
approximately 7 km from the transmitter. Set the operating (carrier) frequency to
10 GHz. To simulate a monostatic radar, set the InUseOutputPort property on the
transmitter to true. Calculate the range and angle from the transmitter to the target.
8-13
8 Detection
hsensor = phased.IsotropicAntennaElement(...
'FrequencyRange',[5e9 15e9]);
htx = phased.Transmitter('Gain',20,'InUseOutputPort',true);
fc = 10e9;
htgt = phased.RadarTarget('Model','Nonfluctuating',...
'MeanRCS',1,'OperatingFrequency',fc);
txloc = [0;0;0];
tgtloc = [5000;5000;10];
htxloc = phased.Platform('InitialPosition',txloc);
htgtloc = phased.Platform('InitialPosition',tgtloc);
[tgtrng,tgtang] = rangeangle(htgtloc.InitialPosition,...
htxloc.InitialPosition);
hwav = phased.RectangularWaveform('PulseWidth',25e-6,...
'OutputFormat','Pulses','PRF',1e4,'NumPulses',1);
c = physconst('LightSpeed');
maxrange = c/(2*hwav.PRF);
SNR = npwgnthresh(1e-6,1,'noncoherent');
Pt = radareqpow(c/fc,maxrange,SNR,...
hwav.PulseWidth,'RCS',htgt.MeanRCS,'Gain',htx.Gain);
Set the peak transmit power to the output value from radareqpow.
htx.PeakPower = Pt;
Create radiator and collector objects that operate at 10 GHz. Create a free space path
for the propagation of the pulse to and from the target. Then, create a receiver and a
matched filter for the rectangular waveform.
hrad = phased.Radiator('PropagationSpeed',c,...
'OperatingFrequency',fc,'Sensor',hsensor);
hspace = phased.FreeSpace('PropagationSpeed',c,...
'OperatingFrequency',fc,'TwoWayPropagation',false);
hcol = phased.Collector('PropagationSpeed',c,...
'OperatingFrequency',fc,'Sensor',hsensor);
hrec = phased.ReceiverPreamp('NoiseFigure',0,...
'EnableInputPort',true,'SeedSource','Property','Seed',2e3);
8-14
Matched Filtering
hmf = phased.MatchedFilter(...
'Coefficients',getMatchedFilter(hwav),...
'GainOutputPort',true);
After you create all the objects that define your model, you can propagate the pulse to
and from the target. Collect the echo at the receiver, and implement the matched filter to
improve the SNR.
% Generate waveform
wf = step(hwav);
% Transmit waveform
[wf,txstatus] = step(htx,wf);
% Radiate pulse toward the target
wf = step(hrad,wf,tgtang);
% Propagate pulse toward the target
wf = step(hspace,wf,txloc,tgtloc,[0;0;0],[0;0;0]);
% Reflect it off the target
wf = step(htgt,wf);
% Propagate the pulse back to transmitter
wf = step(hspace,wf,tgtloc,txloc,[0;0;0],[0;0;0]);
% Collect the echo
wf = step(hcol,wf,tgtang);
8-15
8 Detection
8-16
Stretch Processing
Stretch Processing
In this section...
“Reasons for Using Stretch Processing” on page 8-17
“Support for Stretch Processing” on page 8-17
“Stretch Processing Procedure” on page 8-17
8-17
8 Detection
• periodogram
• psd
• findpeaks
5 Convert each peak frequency to the corresponding range value, using the
stretchfreq2rng function.
See Also
phased.StretchProcessor | phased.LinearFMWaveform | findpeaks |
periodogram | stretchfreq2rng
Related Examples
• Range Estimation Using Stretch Processing
8-18
FMCW Range Estimation
1 Dechirp — Dechirp the received signal by mixing it with the transmitted signal. If
you use the dechirp function, the transmitted signal is the reference signal.
2 Find beat frequency — From the dechirped signal, extract the beat frequency
or pair of beat frequencies. If the FMCW signal has a sawtooth shape (up-sweep or
down-sweep sawtooth shape), you extract one beat frequency. If the FMCW signal
has a triangular sweep, you extract up-sweep and down-sweep beat frequencies.
Extracting beat frequencies can use a variety of algorithms. For example, you can
use the following features to help you perform this step:
• pwelch or periodogram
• psd
• findpeaks
• rootmusic
• phased.CFARDetector
3 Compute range — Use the beat frequency or frequencies to compute the
corresponding range value. The beat2range function can perform this computation.
While developing your algorithm, you might also perform these auxiliary tasks:
8-19
8 Detection
• Explore the relationships among your system’s range requirements and parameters of
the FMCW waveform. You can use these functions:
• range2time
• time2range
• range2bw
See Also
phased.FMCWWaveform | phased.RangeDopplerResponse | beat2range |
dechirp | findpeaks | periodogram | pwelch | range2beat | range2bw |
range2time | rdcoupling | rootmusic | time2range
Related Examples
• Automotive Adaptive Cruise Control Using FMCW Technology
8-20
Range-Doppler Response
Range-Doppler Response
In this section...
“Benefits of Producing Range-Doppler Response” on page 8-21
“Support for Range-Doppler Processing” on page 8-21
“Range-Speed Response Pattern of Target” on page 8-23
• See how far away the targets are and how quickly they are approaching or receding.
• Distinguish among targets moving at various speeds at various ranges, in particular:
You can also use the range-Doppler response in nonvisual ways. For example, you can
perform peak detection in the range-Doppler domain and use the information to resolve
the range-Doppler coupling of an FMCW radar system.
8-21
8 Detection
For examples, see the step reference page or “Range-Speed Response Pattern of Target”
on page 8-23.
This procedure is used typically to produce a range-Doppler response for an FMCW radar
system. You can also use this procedure for a system that uses linear FM pulsed signals.
In the case of pulsed signals, you typically use stretch processing to dechirp the signal.
8-22
Range-Doppler Response
In the case of an FMCW waveform with a triangle sweep, the sweeps alternate
between positive and negative slopes. However, phased.RangeDopplerResponse
is designed to process consecutive sweeps of the same slope. To apply
phased.RangeDopplerResponse for a triangle-sweep system, use one of the
following approaches:
Place an isotropic antenna element at the global origin [0;0;0]. Then, place a
target with a nonfluctuating RCS of 1 square meter at [5000;5000;10], which is
approximately 7 km from the transmitter. Set the operating (carrier) frequency to
10 GHz. To simulate a monostatic radar, set the InUseOutputPort property on the
transmitter to true. Calculate the range and angle from the transmitter to the target.
hsensor = phased.IsotropicAntennaElement(...
8-23
8 Detection
'FrequencyRange',[5e9 15e9]);
htx = phased.Transmitter('Gain',20,'InUseOutputPort',true);
fc = 10e9;
htgt = phased.RadarTarget('Model','Nonfluctuating',...
'MeanRCS',1,'OperatingFrequency',fc);
txloc = [0;0;0];
tgtloc = [5000;5000;10];
htxloc = phased.Platform('InitialPosition',txloc);
htgtloc = phased.Platform('InitialPosition',tgtloc);
[tgtrng,tgtang] = rangeangle(htgtloc.InitialPosition,...
htxloc.InitialPosition);
hwav = phased.RectangularWaveform('PulseWidth',2e-6,...
'OutputFormat','Pulses','PRF',1e4,'NumPulses',1);
c = physconst('LightSpeed');
maxrange = c/(2*hwav.PRF);
SNR = npwgnthresh(1e-6,1,'noncoherent');
Pt = radareqpow(c/fc,maxrange,SNR,...
hwav.PulseWidth,'RCS',htgt.MeanRCS,'Gain',htx.Gain);
Set the peak transmit power to the output value from radareqpow.
htx.PeakPower = Pt;
Create radiator and collector objects that operate at 10 GHz. Create a free space path for
the propagation of the pulse to and from the target. Then, create a receiver.
hrad = phased.Radiator(...
'PropagationSpeed',c,...
'OperatingFrequency',fc,'Sensor',hsensor);
hspace = phased.FreeSpace(...
'PropagationSpeed',c,...
'OperatingFrequency',fc,'TwoWayPropagation',false);
hcol = phased.Collector(...
'PropagationSpeed',c,...
'OperatingFrequency',fc,'Sensor',hsensor);
hrec = phased.ReceiverPreamp('NoiseFigure',0,...
'EnableInputPort',true,'SeedSource','Property','Seed',2e3);
8-24
Range-Doppler Response
Propagate 25 pulses to and from the target. Collect the echoes at the receiver, and store
them in a 25-column matrix named rx_puls.
numPulses = 25;
rx_puls = zeros(100,numPulses);
for n = 1:numPulses
% Generate waveform
wf = step(hwav);
% Transmit waveform
[wf,txstatus] = step(htx,wf);
% Radiate pulse toward the target
wf = step(hrad,wf,tgtang);
% Propagate pulse toward the target
wf = step(hspace,wf,txloc,tgtloc,[0;0;0],[0;0;0]);
% Reflect it off the target
wf = step(htgt,wf);
% Propagate the pulse back to transmitter
wf = step(hspace,wf,tgtloc,txloc,[0;0;0],[0;0;0]);
% Collect the echo
wf = step(hcol,wf,tgtang);
% Receive target echo
rx_puls(:,n) = step(hrec,wf,~txstatus);
end
Create a range-Doppler response object that uses the matched filter approach. Configure
this object to show radial speed rather than Doppler frequency. Use plotResponse to
plot the range versus speed.
hrdr = phased.RangeDopplerResponse(...
'RangeMethod','Matched Filter',...
'PropagationSpeed',c,...
'DopplerOutput','Speed','OperatingFrequency',fc);
plotResponse(hrdr,rx_puls,getMatchedFilter(hwav))
8-25
8 Detection
See Also
phased.RangeDopplerResponse
Related Examples
• Automotive Adaptive Cruise Control Using FMCW Technology
8-26
Constant False-Alarm Rate (CFAR) Detectors
In this section...
“Reasons for Using CFAR Detectors” on page 8-27
“Cell-Averaging CFAR Detector” on page 8-28
“Testing CFAR Detector Adaption to Noisy Input Data” on page 8-30
“Extensions of Cell-Averaging CFAR Detector” on page 8-31
“Detection Probability for CFAR Detector” on page 8-31
To motivate the need for an adaptive procedure, assume a simple binary hypothesis test
where you must decide between these hypotheses for a single sample:
H0 : x[ 0 ] = w[ 0 ] w[ 0 ] ~ N ( 0,1)
H1 : x[ 0 ] = 4 + w[ 0]
T = npwgnthresh(1e-3,1,'real');
threshold = sqrt(db2pow(T))
Check that this threshold yields the desired false-alarm rate probability, and compute
the probability of detection.
8-27
8 Detection
Pd = 0.5*erfc((threshold-4)/sqrt(2))
Next, assume that the noise power increases by 6.02 dB, doubling the noise variance. If
your detector does not adapt to this increase in variance by determining a new threshold,
your false-alarm rate increases significantly.
Pfa = 0.5*erfc(threshold/2)
The following figure demonstrates the effect of increasing the noise variance on the false-
alarm probability for a fixed threshold.
noisevar = 1:0.1:10;
Noisepower = 10*log10(noisevar);
Pfa = 0.5*erfc(threshold./sqrt(2*noisevar));
semilogy(Noisepower,Pfa./1e-3);
grid on; title('Increase in P_{FA} due to Noise Variance');
ylabel('Increase in P_{FA} (Orders of Magnitude)');
xlabel('Noise Power Increase (dB)');
8-28
Constant False-Alarm Rate (CFAR) Detectors
This assumption is key in justifying the use of the training cells to estimate the noise
variance in the CUT. Additionally, the cell-averaging CFAR detector assumes that the
training cells do not contain any signals from targets. Thus, the data in the training cells
are assumed to consist of noise only.
• It is preferable to have some buffer, or guard cells, between the CUT and the training
cells. The buffer provided by the guard cells guards against signal leaking into the
training cells and adversely affecting the estimation of the noise variance.
• The training cells should not represent range cells too distant in range from the CUT,
as the following figure illustrates.
The optimum estimator for the noise variance depends on distributional assumptions and
the type of detector. Assume the following:
Note: If you denote this RV by Z=U+jV, the squared magnitude |Z|2 follows an
exponential distribution with mean σ2.
If the samples in training cells are the squared magnitudes of such complex Gaussian
RVs, you can use the sample mean as an estimator of the noise variance.
8-29
8 Detection
Create a CFAR detector object with two guard cells, 20 training cells, and a false-alarm
probability of 0.001. By default, this object assumes a square-law detector with no pulse
integration.
hdetector = phased.CFARDetector('NumGuardCells',2,...
'NumTrainingCells',20,'ProbabilityFalseAlarm',1e-3);
There are 10 training cells and 1 guard cell on each side of the cell under test (CUT). Set
the CUT index to 12.
CUTidx = 12;
Seed the random number generator for a reproducible set of input data.
rng(1000);
Set the noise variance to 0.25. This value corresponds to an approximate –6 dB SNR.
Generate a 23-by-10000 matrix of complex-valued, white Gaussian RVs with the specified
variance. Each row of the matrix represents 10,000 Monte Carlo trials for a single cell.
Ntrials = 1e4;
variance = 0.25;
Ncells = 23;
inputdata = sqrt(variance/2)*(randn(Ncells,Ntrials)+...
1j*randn(Ncells,Ntrials));
Because the example implements a square-law detector, take the squared magnitudes of
the elements in the data matrix.
Z = abs(inputdata).^2;
Provide the output of the square-law operator and the index of the cell under test to
CFAR detector's step method.
8-30
Constant False-Alarm Rate (CFAR) Detectors
Z_detect = step(hdetector,Z,CUTidx);
The output is a logical vector Z_detect with 10,000 elements. Sum the elements in
Z_detect and divide by the total number of trials to obtain the empirical false-alarm
rate.
Pfa = sum(Z_detect)/Ntrials
The empirical false-alarm rate is 0.0013, which corresponds closely to the desired false-
alarm rate of 0.001.
Ntraining = 10;
Nguard = 2;
Pfa_goal = 0.01;
hdet = phased.CFARDetector('Method','CA',...
'NumTrainingCells',Ntraining,'NumGuardCells',Nguard,...
8-31
8 Detection
'ProbabilityFalseAlarm',Pfa_goal);
The detector has 2 guard cells, 10 training cells, and a false-alarm probability of 0.01.
This object assumes a square-law detector with no pulse integration.
In the input data, replace rows 8 and 12 to simulate two targets for the CFAR detector to
detect.
inputdata(8,:) = 3*exp(1i*2*pi*rand);
inputdata(12,:) = 9*exp(1i*2*pi*rand);
Because the example implements a square-law detector, take the squared magnitudes of
the elements in the input data vector.
Z = abs(inputdata).^2;
The Z_detect matrix has five rows. The first and last rows correspond to the simulated
targets. The three middle rows correspond to noise.
Compute the probability of detection of the two targets. Also, estimate the probability of
false alarm using the noise-only rows.
Pd_1 = sum(Z_detect(1,:))/Ntrials
Pd_2 = sum(Z_detect(end,:))/Ntrials
Pfa = max(sum(Z_detect(2:end-1,:),2)/Ntrials)
Pd_1 =
Pd_2 =
8-32
Constant False-Alarm Rate (CFAR) Detectors
Pfa =
6.0000e-05
The 0 value of Pd_1 indicates that this detector does not detect the first target.
Change the CFAR detector so it uses the order statistic CFAR algorithm with a rank of 5.
release(hdet);
hdet.Method = 'OS';
hdet.Rank = 5;
Pd_1 =
0.5820
Pd_2 =
Pfa =
0.0066
Using the order statistic algorithm instead of the cell-averaging algorithm, the detector
detects the first target in about 58% of the trials.
8-33
8-34
9
In this section...
“Support for Modeling Propagation in Free Space” on page 9-2
“Free Space Path Loss in Decibels” on page 9-2
“Propagation of a Linear FM Pulse Waveform to and from a Target” on page 9-3
“One-Way and Two-Way Propagation” on page 9-4
“Propagation from Stationary Radar to Moving Target” on page 9-5
• 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.
9-2
Free Space Path Loss
Determine the free space path loss in decibels for a narrowband signal propagating to
and from the target.
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.
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');
9-3
9 Environment and Target Models
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.
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,...
9-4
Free Space Path Loss
'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.
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);
Define the signal’s sample rate, propagation speed, and carrier frequency. Define the
signal as a sinusoid of frequency 150 Hz.
9-5
9 Environment and Target Models
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')
9-6
Free Space Path Loss
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');
9-7
9 Environment and Target Models
9-8
Radar Target
Radar Target
The phased.RadarTarget object models a reflected signal from a target with
nonfluctuating or fluctuating radar cross section (RCS). This object has the following
modifiable properties:
Create a radar target with a nonfluctuating RCS of 1 square meter and an operating
frequency of 300 MHz. Specify a wave propagation speed equal to the speed of light.
hr = phased.RadarTarget('Model','nonfluctuating','MeanRCS',1,...
'PropagationSpeed',physconst('LightSpeed'),...
'OperatingFrequency',3e8);
4ps
G=
l2
Here, σ represents the target mean RCS, and λ is the wavelength of the operating
frequency. Each element of the signal incident on the target is scaled by the preceding
factor.
Create a target with a nonfluctuating RCS of 1 square meter. Set the operating frequency
to 1 GHz. Set the signal incident on the target to be a vector of ones to demonstrate the
gain factor.
hr = phased.RadarTarget('MeanRCS',1,'OperatingFrequency',1e9);
x = ones(10,1);
y = step(hr,x);
9-9
9 Environment and Target Models
lambda = hr.PropagationSpeed/hr.OperatingFrequency;
G = sqrt(4*pi*1/lambda^2)
The previous examples used nonfluctuating values for the target's RCS. This model is not
valid in many scenarios. There are several cases where the RCS exhibits relatively small
or large magnitude fluctuations. These fluctuations can occur rapidly on pulse-to-pulse,
or more slowly, on scan-to-scan time scales:
To account for significant fluctuations in the RCS, you need to use statistical models.
The four Swerling models, described in the following table, are widely used to cover these
kinds of fluctuating-RCS cases.
9-10
Radar Target
You can simulate a Swerling target model by setting the Model property. Use the step
method and set the UPDATERCS input argument to true or false. Setting UPDATERCS to
true updates the RCS value according to the specified probability model each time you
call step. If you set UPDATERCS to false, the previous RCS value is used.
This example creates and transmits a linear FM waveform with a 1 GHz carrier
frequency. The waveform is transmitted and collected by an isotropic antenna with
a back-baffled response. The waveform propagates to and from a target with a
nonfluctuating RCS of 1 square meter. The target is located approximately 1414 meters
from the antenna at an angle of 45 degrees azimuth and 0 degrees elevation.
% Create objects and assign property values
% Isotropic antenna element
hant = phased.IsotropicAntennaElement('BackBaffled',true);
% Location of the antenna
harraypos = phased.Platform('InitialPosition',[0;0;0]);
% Location of the radar target
hrfpos = phased.Platform('InitialPosition',[1000; 1000; 0]);
% Linear FM waveform
hwav = phased.LinearFMWaveform('PulseWidth',100e-6);
% Transmitter
htx = phased.Transmitter('PeakPower',1e3,'Gain',40);
% Waveform radiator
hrad = phased.Radiator('OperatingFrequency',1e9, ...
'Sensor',hant);
% Propagation environment to and from the RadarTarget
hspace = phased.FreeSpace('OperatingFrequency',1e9,...
'TwoWayPropagation',true);
% Radar target
hr = phased.RadarTarget('MeanRCS',1,'OperatingFrequency',1e9);
% Collector
hc = phased.Collector('OperatingFrequency',1e9,...
'Sensor',hant);
% Implement system
wf = step(hwav); % generate waveform
9-11
9 Environment and Target Models
9-12
Clutter Modeling
Clutter Modeling
In this section...
“Surface Clutter Overview” on page 9-13
“Approaches for Clutter Simulation or Analysis” on page 9-13
“Considerations for Setting Up a Constant Gamma Clutter Simulation” on page 9-14
“Related Examples” on page 9-15
If you are simulating a radar system, you might want to incorporate surface clutter into
the simulation to ensure the system can overcome the effects of surface clutter. If you are
analyzing the statistical performance of a radar system, you might want to incorporate
clutter return distributions into the analysis.
• billingsleyicm
• depressionang
• effearthradius
• grazingang
• horizonrange
• surfclutterrcs
9-13
9 Environment and Target Models
• surfacegamma
• Propagation speed, sample rate, and pulse repetition frequency of the signal
• Operating frequency of the system
• Altitude, speed, and direction of the radar platform
• Depression angle of the broadside of the radar antenna array
Clutter-Related Properties
The object has properties that correspond to the clutter characteristics, location, and
modeling fidelity. These properties include:
• Gamma parameter that depends on the terrain type and system’s operating
frequency.
• Azimuth coverage and maximum range for the clutter simulation.
• Azimuth span of each clutter patch. The software internally divides the clutter ring
into a series of adjacent, nonoverlapping clutter patches.
• Clutter coherence time. This value indicates how frequently the software changes the
set of random numbers in the clutter simulation.
In the simulation, you can use identical random numbers over a time interval or
uncorrelated random numbers. Simulation behavior slightly differs from reality,
where a moving platform produces clutter returns that are correlated with each other
over small time intervals.
9-14
Clutter Modeling
• A fixed number of pulses. You indicate the number of pulses using the NumPulses
property of the object.
• A fixed number of samples. You indicate the number of samples using the
NumSamples property of the object. Typically, you use the number of samples in one
pulse. In staggered PRF applications, you might find this option more convenient
because the step output always has the same matrix size.
Assumptions
Related Examples
• Ground Clutter Mitigation with Moving Target Indication (MTI) Radar
• Introduction to Space-Time Adaptive Processing
• “Example: DPCA Pulse Canceller for Clutter Rejection”
• “Example: Adaptive DPCA Pulse Canceller”
• “Example: Sample Matrix Inversion (SMI) Beamformer”
9-15
9 Environment and Target Models
Barrage Jammer
In this section...
“Support for Modeling Barrage Jammer” on page 9-16
“Model Real and Imaginary Parts of Barrage Jammer Output” on page 9-16
“Model Effect of Barrage Jammer on Target Echo” on page 9-17
The real and imaginary parts of the complex white Gaussian noise sequence each have
variance equal to 1/2 the effective radiated power in watts. Denote the effective radiated
power in watts by P. The barrage jammer output is:
w[ n] = P x[ n ] + j P y[ n]
2 2
In this equation, x[n] and y[n] are mutually uncorrelated sequences of Gaussian random
variables with zero mean and unit variance.
9-16
Barrage Jammer
First, create the required objects. You need an array, a transmitter, a radiator, a target,
a jammer, a collector, and a receiver. Additionally, you need to define two propagation
paths: one from the array to the target and back, and the other path from the jammer to
the array.
hula = phased.ULA(4);
Fs = 1e6;
fc = 1e9;
hwav = phased.RectangularWaveform('PulseWidth',100e-6,...
'PRF',1e3,'NumPulses',5,'SampleRate',Fs);
htx = phased.Transmitter('PeakPower',1e4,'Gain',20,...
'InUseOutputPort',true);
hrad = phased.Radiator('Sensor',hula,'OperatingFrequency',fc);
hjammer = phased.BarrageJammer('ERP',1000,...
'SamplesPerFrame',hwav.NumPulses*hwav.SampleRate/hwav.PRF);
htarget = phased.RadarTarget('Model','Nonfluctuating',...
9-17
9 Environment and Target Models
'MeanRCS',1,'OperatingFrequency',fc);
htargetpath = phased.FreeSpace('TwoWayPropagation',true,...
'SampleRate',Fs,'OperatingFrequency', fc);
hjammerpath = phased.FreeSpace('TwoWayPropagation',false,...
'SampleRate',Fs,'OperatingFrequency', fc);
hcollector = phased.Collector('Sensor',hula,...
'OperatingFrequency',fc);
hrc = phased.ReceiverPreamp('EnableInputPort',true);
Assume that the array, target, and jammer are stationary. The array is located at the
global origin, [0;0;0]. The target is located at [1000 ;500;0], and the jammer is
located at [2000;2000;100]. Determine the directions from the array to the target and
jammer.
Finally, transmit the rectangular pulse waveform to the target, reflect it off the target,
and collect the echo at the array. Simultaneously, the jammer transmits a jamming
signal toward the array. The jamming signal and echo are mixed at the receiver.
% Generate waveform
wf = step(hwav);
% Transmit waveform
[wf,txstatus] = step(htx,wf);
% Radiate pulse toward the target
wf = step(hrad,wf,tgtang);
% Propagate pulse toward the target
wf = step(htargetpath,wf,[0;0;0],targetloc,[0;0;0],[0;0;0]);
% Reflect it off the target
wf = step(htarget,wf);
% Collect the echo
wf = step(hcollector,wf,tgtang);
9-18
Barrage Jammer
Plot the result, and compare it with received waveform with and without jamming.
subplot(2,1,1);
t = unigrid(0,1/Fs,size(pulsewave,1)*1/Fs,'[)');
plot(t,abs(pulsewave(:,1)));
title('Magnitudes of Pulse Waveform Without Jamming--Element 1')
ylabel('Magnitude');
subplot(2,1,2);
plot(t,abs(pulsewave_jamsig(:,1)));
title('Magnitudes of Pulse Waveform with Jamming--Element 1')
xlabel('Seconds'); ylabel('Magnitude');
9-19
9-20
10
Rectangular Coordinates
In this section...
“Definitions of Coordinates” on page 10-2
“Notation for Vectors and Points” on page 10-3
“Orthogonal Basis and Euclidean Norm” on page 10-3
“Orientation of Coordinate Axes” on page 10-4
“Rotations and Rotation Matrices” on page 10-7
Definitions of Coordinates
Construct a rectangular, or Cartesian, coordinate system for three-dimensional space
by specifying three mutually orthogonal coordinate axes. The following figure shows one
possible specification of the coordinate axes.
You can view the 3-tuple as a point in space, or equivalently as a vector in three-
dimensional Euclidean space. Viewed as a vector space, the coordinate axes are basis
10-2
Rectangular Coordinates
vectors and the vector gives the direction to a point in space from the origin. Every vector
in space is uniquely determined by a linear combination of the basis vectors. The most
common set of basis vectors for three-dimensional Euclidean space are the standard unit
basis vectors:
Note: In this software, all coordinate vectors are column vectors. For convenience,
the documentation represents column vectors in the format [x y z] without transpose
notation.
Both the vector notation [x y z] and point notation (x,y,z) are used interchangeably. The
interpretation of the column vector as a vector or point depends on the context. If the
column vector specifies the axes of a coordinate system or direction, it is a vector. If the
column vector specifies coordinates, it is a point.
The standard distance measure in space is the l2 norm, or Euclidean norm. The
Euclidean norm of a vector [x y z] is defined by:
x2 + y2 + z2
The Euclidean norm gives the length of the vector measured from the origin as the
hypotenuse of a right triangle. The distance between two vectors [x0 y0 z0] and [x1 y1 z1] is:
( x0 − x1 ) 2 + ( y0 − y1) 2 + ( z0 − z1) 2
10-3
10 Coordinate Systems and Motion Modeling
If you take your right hand and point it along the positive x-axis with your palm facing
the positive y-axis and extend your thumb, your thumb indicates the positive direction of
the z-axis.
For some array geometries, it is convenient to define the origin as the phase center of the
array. For example, create a default uniform linear array (ULA) and query the element
coordinates:
H = phased.ULA('NumElements',2,'ElementSpacing',0.5)
getElementPosition(H)
The following figure illustrates the default ULA with array elements located at ( 0, –0.25,
0) and (0, 0.25, 0).
10-4
Rectangular Coordinates
, 0)
0.25
(0,
, 0)
-0.25
(0,
x
The next example creates a uniform rectangular array (URA) with four elements:
10-5
10 Coordinate Systems and Motion Modeling
Boresight Direction
The direction that an antenna is facing when transmitting and receiving a signal
is referred to as the boresight, or look direction. The convention in this software for
specifying coordinate axes designates the positive x-axis as the boresight direction. The
following figure shows a right-handed coordinate system with the positive x-axis oriented
along the sensor boresight direction.
z
In ULAs and URAs, the boresight directions of all the array elements are equal. In the
case of the ULA, the y-axis is aligned with the array element apertures. This alignment
is referred to as the array axis. The array elements have a common boresight direction,
which the toolbox designates as the x-axis. The x-axis is orthogonal, or normal, to the
array axis.
In the case of the URA, the array element apertures lie in the yz plane and also exhibit
a common boresight direction. The x-axis is normal to the plane containing the array
elements. This alignment illustrates the software convention that the x-axis is the
direction normal to the array.
In the case of conformal arrays, the elements do not share a common boresight direction
and the direction normal to each element is a property of the individual array elements.
10-6
Rectangular Coordinates
The rotation matrices that rotate a vector around the x, y, and z-axes are given by:
È1 0 0 ˘
Í
Rx (a ) = Í0 cos a - sin a ˙˙
ÍÎ0 sin a cos a ˙˚
È cos b 0 sin b ˘
Ry ( b ) = ÍÍ 0 1 0 ˙˙
ÍÎ - sin b 0 cos b ˙˚
È cos g - sin g 0˘
Rz (g ) = ÍÍ sin g cos g 0 ˙˙
ÍÎ 0 0 1 ˙˚
The following three figures show what positive rotations look like for each rotation axis:
10-7
10 Coordinate Systems and Motion Modeling
10-8
Rectangular Coordinates
10-9
10 Coordinate Systems and Motion Modeling
For any rotation, there is an inverse rotation satisfying A -1 A = 1 . For example, the
inverse of the x-axis rotation matrix is obtained by changing the sign of the angle:
È1 0 0 ˘
Rx-1 (a ) Í
= Rx ( -a ) = Í0 cos a sin a ˙˙ = R¢x (a )
ÍÎ0 - sin a cos a ˙˚
This example illustrates a basic property: the inverse rotation matrix equals the
transpose of the original. Rotation matrices satisfy A’A = 1, and consequently det(A) = 1.
Under rotations, vector lengths are preserved as well as the angles between vectors.
We can think of rotations in another way. Consider the original set of basis vectors,
i, j, k , and rotate them all using the rotation matrix A. This produces a new set of basis
10-10
Rectangular Coordinates
i¢ = Ai
j¢ = Aj
k ¢ = Ak
The new basis vectors can be written as linear combinations of the old ones and involve
the transpose:
È i¢ ˘ Èi ˘
Í j¢ ˙ = A ¢ Í j ˙
Í ˙ Í ˙
ÍÎk ¢˙˚ ÍÎk ˙˚
Now any vector can be written as a linear combination of either set of basis vectors:
Using some algebraic manipulation, one can derive the transformation of components for
a fixed vector when the basis (or coordinate system) rotates
Èv¢x ˘ È vx ˘ È vx ˘
Í ˙ -1 Í ˙ Í ˙
Ív¢y ˙ = A Í vy ˙ = A ¢ Ív y ˙
Í v¢ ˙ Ív ˙ Ív ˙
Î z˚ Î z˚ Î z˚
Thus the change in components of a vector when the coordinate system rotates involves
the transpose of the rotation matrix. The next figure illustrates how a vector stays fixed
as the coordinate system rotates around the x-axis. The figure after shows how this can
be interpreted as a rotation of the vector in the opposite direction.
10-11
10 Coordinate Systems and Motion Modeling
10-12
Rectangular Coordinates
More About
• “Global and Local Coordinate Systems” on page 10-22
10-13
10 Coordinate Systems and Motion Modeling
Spherical Coordinates
In this section...
“Support for Spherical Coordinates” on page 10-14
“Azimuth and Elevation Angles” on page 10-14
“Phi and Theta Angles” on page 10-15
“U and V Coordinates” on page 10-16
“Conversion Between Rectangular and Spherical Coordinates” on page 10-17
“Broadside Angle” on page 10-18
• Use the azimuth angle, az, and the elevation angle, el, to define the location of a point
on the unit sphere.
• Specify all angles in degrees.
• List coordinates in the sequence (az,el,R).
The azimuth angle is the angle from the positive x-axis toward the positive y-axis, to the
vector’s orthogonal projection onto the xy plane. The azimuth angle is between –180 and
10-14
Spherical Coordinates
180 degrees. The elevation angle is the angle from the vector’s orthogonal projection onto
the xy plane toward the positive z-axis, to the vector. The elevation angle is between –90
and 90 degrees. These definitions assume the boresight direction is the positive x-axis.
Note: The elevation angle is sometimes defined in the literature as the angle a vector
makes with the positive z-axis. The MATLAB and Phased Array System Toolbox
products do not use this definition.
This figure illustrates the azimuth angle and elevation angle for a vector that appears
as a green solid line. The coordinate system is relative to the center of a uniform linear
array, whose elements appear as blue circles.
The φ angle is the angle from the positive y-axis toward the positive z-axis, to the vector’s
orthogonal projection onto the yz plane. The φ angle is between 0 and 360 degrees. The θ
angle is the angle from the x-axis toward the yz plane, to the vector itself. The θ angle is
between 0 and 180 degrees.
10-15
10 Coordinate Systems and Motion Modeling
The figure illustrates φ and θ for a vector that appears as a green solid line. The
coordinate system is relative to the center of a uniform linear array, whose elements
appear as blue circles.
The coordinate transformations between φ/θ and az/el are described by the following
equations
U and V Coordinates
In radar applications, it is often useful to parameterize the hemisphere x ≥ 0 using
coordinates denoted by u and v.
• To convert the φ/θ representation to and from the corresponding u/v representation,
use coordinate conversion functions phitheta2uv and uv2phitheta.
• To convert the azimuth/elevation representation to and from the corresponding u/v
representation, use coordinate conversion functions azel2uv and uv2azel.
10-16
Spherical Coordinates
u = sin q cos f
v = sin q sin f
In these expressions, φ and θ are the phi and theta angles, respectively.
u = cos el sin az
v = sin el
Conversely, the phi and theta angles can be written in terms of u and v using
tan f = u / v
sin q = u2 + v2
The azimuth and elevation angles can also be written in terms of u and v
sin el = v
u
tan az =
1 - u2 - v2
R= x2 + y2 + z2
az = tan -1 ( y / x)
el = tan-1 ( z / x2 + y2 )
10-17
10 Coordinate Systems and Motion Modeling
When specifying a target’s location with respect to a phased array, it is common to refer
to its distance and direction from the array. The distance from the array corresponds to R
in spherical coordinates. The direction corresponds to the azimuth and elevation angles.
Tip To convert between rectangular coordinates and (az,el,R), use the MATLAB functions
cart2sph and sph2cart. These functions specify angles in radians. To convert between
degrees and radians, use degtorad and radtodeg.
Broadside Angle
The special case of the uniform linear arrays (ULA) uses the concept of the broadside
angle. The broadside angle is the angle measured from array normal direction projected
onto the plane determined by the signal incident direction and the array axis to the
signal incident direction. Broadside angles assume values in the interval [–90,90]
degrees. The following figure illustrates the definition of the broadside angle.
The shaded gray area in the figure is the plane determined by the signal incident
direction and the array axis. The broadside angle is positive when measured toward the
10-18
Spherical Coordinates
positive direction of the array axis. A number of algorithms for ULAs use the broadside
angle instead of the azimuth and elevation angles. The algorithms do so because the
broadside angle more accurately describes the ability to discern direction of arrival with
this geometry.
Expressing the broadside angle in terms of the azimuth and elevation angles reveals a
number of important characteristics, including:
• For an elevation angle of zero degrees, the broadside angle is equal to the azimuth
angle.
• Elevation angles equally above and below the xy plane result in identical broadside
angles.
The following figure depicts a ULA with elements spaced d meters apart. The ULA is
illuminated by a plane wave emitted from a point source in the far field. For convenience,
the elevation angle is zero degrees. The plane determined by the signal incident direction
and the array axis is the xy plane. The broadside angle reduces to the azimuth angle.
10-19
10 Coordinate Systems and Motion Modeling
Source
d sin(β)
β
1 2 3 4 5
Because of the angle of arrival, the array elements are not simultaneously illuminated
by the plane wave. The additional distance the incident wave travels between array
elements is d sin(β) where d is the distance between array elements. Therefore, the
constant time delay between array elements is:
d sin( b )
t = ,
c
For broadside angles of ±90 degrees, the plane wave is incident on the array along the
array axis and the time delay between sensors reduces to ±d/c. For a broadside angle of 0
degrees, the plane wave illuminates all elements of the ULA simultaneously and the time
delay between elements is zero.
The following examples show the use of the utility functions az2broadside and
broadside2az:
bsang = az2broadside(45,60)
% approximately 21 degrees
10-20
Spherical Coordinates
10-21
10 Coordinate Systems and Motion Modeling
In this section...
“Global Coordinate System” on page 10-22
“Local Coordinate System” on page 10-23
“Converting Between Global and Local Coordinate Systems” on page 10-27
To extract useful information from this environment, you often need to analyze data
from multiple phased arrays over time. Each phased array senses the environment from
its own local perspective. To put the information from each phased array into a global
perspective, you must know the location of each array in the global coordinate system
and the orientation of the array’s coordinate axes.
In the following figure, the solid dark axes denote the coordinate axes of a global
coordinate system. There are two phased arrays, Array 1, and Array 2. Each of the
phased arrays defines its own coordinate system within the global system denoted by the
dashed lines. A target is indicated by the black circle.
10-22
Global and Local Coordinate Systems
The two phased arrays detect the target and estimate target characteristics such as
range and velocity. To translate information about the target derived from the two
spatially-separated phased arrays, you must know the positions of the phased arrays and
the orientation of their local coordinate axes with respect to the global coordinate system.
Note: In specifying a global coordinate system, you can designate any point as the origin.
The coordinate axes must be orthogonal.
10-23
10 Coordinate Systems and Motion Modeling
but they do not need to be parallel to the global coordinate axes. The local origin may
be located anywhere in the global coordinate system and need not be stationary. For
example, a vehicle-mounted phased array has its own local coordinate system, which
moves within the global coordinate system.
You can specify target locations with respect to a local coordinate system in terms
of range and direction of arrival. A target’s range corresponds to R, the Euclidean
distance in spherical coordinates. The direction of arrival corresponds to the azimuth
and elevation angles. Phased Array System Toolbox software follows the MATLAB
convention and lists spherical coordinates in the order: (az,el,R).
The positions of all array elements in this software are in local coordinates. The following
examples illustrate local coordinate systems for uniform linear, uniform rectangular, and
conformal arrays.
For a uniform linear array (ULA), the origin of the local coordinate system is the phase
center of the array. The positive x-axis is the direction normal to the array, and the
elements of the array are located along the y-axis. The y-axis is referred to as the array
axis. Define the axis normal to the array as the span of the vector [1 0 0] and the array
axis as the span of the vector [0 1 0]. The z-axis is the span of the vector [0 0 1], which is
the cross product of the two vectors: [1 0 0] and [0 1 0].
H = phased.ULA('NumElements',2,'ElementSpacing',0.5)
getElementPosition(H)
The following figure illustrates the default ULA in a local right-handed coordinate
system:
10-24
Global and Local Coordinate Systems
, 0)
0.25
(0,
, 0)
-0.25
(0,
x
The elements are located 0.25 meters from the phase center of the array and the distance
between the two elements is 0.5 meters.
H = phased.ULA('NumElements',8,'ElementSpacing',0.25)
% Invoke the getElementPosition method
% to see the local coordinates of the elements
getElementPosition(H)
In a uniform rectangular array (URA), the origin of the local coordinate system is the
phase center of the array. The x-axis is the direction normal to the array. In the yz plane,
the array elements have even row spacing and even column spacing.
Construct a URA:
10-25
10 Coordinate Systems and Motion Modeling
Construct a uniform rectangular array with two elements along the y-axis and three
elements along the z-axis.
Ha = phased.URA([2 3])
ElementLocs2by3 = getElementPosition(Ha)
In a conformal array, the phase center of the array may be defined at an arbitrary point.
In principle, the orientation of each element in a conformal array may be different.
Therefore, it is convenient to define the array by giving the element locations with
respect to the local coordinate system origin along with the azimuth and elevation angles
defining the boresight directions.
H = phased.ConformalArray
% query element position and element normal
H.ElementPosition
H.ElementNormal
The default conformal array consists of a single element located at [0 0 0], the origin of
the local coordinate system. The boresight direction of the single element is specified by
the azimuth and elevation angles (in degrees) in the ElementNormal property, [0 0].
10-26
Global and Local Coordinate Systems
Construct a conformal array with three elements located at [1 0 0], [0 1 0], and [0 –1 0]
with respect to the origin. Define the normal direction to the first element as 0 degrees
azimuth and elevation. Define the normal direction to the second and third elements as
45 degrees azimuth and elevation.
H = phased.ConformalArray(...
'ElementPosition',[1 0 0; 0 1 0; 0 -1 0]',...
'ElementNormal',[0 45 45; 0 45 45])
Assume a stationary target 1000 meters from a URA at an azimuth angle of 30 degrees
and elevation angle of 45 degrees. The phase center of the URA is located at the
rectangular coordinates [1000 500 100] in the global coordinate system. The local
coordinate axes of the URA are parallel to the global coordinate axes. Determine the
position of the target in rectangular coordinates in the global coordinate system.
In this example, the target’s location is specified in local spherical coordinates. The
target is 1000 meters from the array, which means that R=1000.The azimuth angle of 30
degrees and elevation angle of 45 degrees give the direction of the target from the array.
The spherical coordinates of the target in the local coordinate system are (30,45,1000).
To convert to global rectangular coordinates, you must know the position of the array in
global coordinates. The phase center of the array is located at [1000 500 100]. To convert
from local spherical coordinates to global rectangular coordinates, use the 'sr' option.
Assume a stationary target with global rectangular coordinates [5000 3000 50]. The
phase center of a URA has global rectangular coordinates [1000 500 10]. The local
coordinate axes of the URA are [0 1 0], [1 0 0], and [0 0 –1]. Determine the position of the
target in local spherical coordinates.
lCoord = global2localcoord([5000; 3000; 50],'rs',...
10-27
10 Coordinate Systems and Motion Modeling
The output lCoord is in the form (az,el,R). The target in local coordinates has an
azimuth of approximately 58 degrees, an elevation of 0.5 degrees, and a range of 4717.16
m.
10-28
Motion Modeling in Phased Array Systems
In this section...
“Support for Motion Modeling” on page 10-29
“Platform Motion with Constant Velocity” on page 10-30
“Platform Motion with Nonconstant Velocity” on page 10-31
“Track Range and Angle Changes Between Platforms” on page 10-32
Extended bodies can undergo both translational and rotational motion in space. Phased
Array System Toolbox software supports modeling of translational motion.
Let r0 denote the position vector at time 0 and v denote the velocity vector. The position
vector of a platform as a function of time, r(t), is:
r (t) = r0 + vt
10-29
10 Coordinate Systems and Motion Modeling
r(t0)
r0=r(0)
vt
r(t)=r0+vt
When the platform represents a sensor element or array, it is important to know the
orientation of the element or array local coordinate axes. For example, the orientation
of the local coordinate axes is necessary to extract angle information from incident
waveforms. See “Global and Local Coordinate Systems” on page 10-22 for a description
of global and local coordinate systems in the software. Finally, for platforms with
nonconstant velocity, you must be able to update the velocity vector over time.
You can model platform position, velocity, and local axes orientation with the
phased.Platform object.
10-30
Motion Modeling in Phased Array Systems
The orientation of the local coordinate axes of the platform is the value of
the OrientationAxes property. You can view the value of this property by
entering hplat.OrientationAxes at the MATLAB command prompt. Because
the OrientationAxes property is not specified in the construction of the
phased.Platform object, the property is assigned its default value of [1 0 0;0 1 0;0
0 1].
Use the step method to simulate the translational motion of the platform.
InitialPos = hplat.InitialPosition;
for k = 1:Nsteps
pos = step(hplat,Tstep);
end
FinalPos = pos+hplat.Velocity*Tstep;
DistTravel = norm(FinalPos-InitialPos);
The step method returns the current position of the platform and then updates the
platform position based on the time step and velocity. Equivalently, the first time you
invoke the step method, the output is the position of the platform at t=0.
Recall that the platform is moving with a constant velocity of approximately 30 m/s.
The total time elapsed is 0.01 seconds. Invoking the step method returns the current
position of the platform and then updates that position. Accordingly, you expect the
final position to differ from the initial position by 0.30 meters. Confirm this difference by
examining the value of DistTravel.
In this example, assume you model a target initially at rest. The initial velocity vector is
(0,0,0). Assume the time step is 1 millisecond. After 500 milliseconds, the platform begins
to move with a speed of approximately 10 m/s. The velocity vector is (7.07,7.07,0). The
platform continues at this velocity for an additional 500 milliseconds.
10-31
10 Coordinate Systems and Motion Modeling
Tstep = 1e-3;
Nsteps = 1/Tstep;
hplat = phased.Platform('InitialPosition',[100;100;0]);
for k = 1:Nsteps/2
[pos,vel] = step(hplat,Tstep);
end
hplat.Velocity = [7.07; 7.07; 0];
for k=Nsteps/2+1:Nsteps
[pos,vel] = step(hplat,Tstep);
end
The example uses phased.Platform to model the motion of the target and radar. The
global2localcoord function translates the target’s rectangular coordinates in the
global coordinate system to spherical coordinates in the local coordinate system of the
radar.
PRF = 1e3;
Tstep = 1/PRF;
hradar = phased.Platform('InitialPosition',[1000;1000;0]);
htgt = phased.Platform('InitialPosition',[5000;8000;0],...
'Velocity',[-30;-45;0]);
% Calculate initial target range and angle
[InitRng, InitAng] = rangeangle(htgt.InitialPosition,...
hradar.InitialPosition);
% Calculate relative radial speed
v = radialspeed(htgt.InitialPosition,htgt.Velocity,...
hradar.InitialPosition);
% Simulate target motion
Npulses = 10; % Number of pulses
for num = 1:Npulses
tgtpos = step(htgt,Tstep);
end
tgtpos = tgtpos+htgt.Velocity*Tstep;
% Calculate final target range and angle
[FinalRng,FinalAng] = rangeangle(tgtpos,...
10-32
Motion Modeling in Phased Array Systems
hradar.InitialPosition);
DeltaRng = FinalRng-InitRng;
The constant velocity of the target is approximately 54 m/s. The total time elapsed is 0.01
seconds. The range between the target and the radar should decrease by approximately
54 centimeters. Compare the initial range of the target, InitRng, to the final range,
FinalRng, to confirm that this decrease occurs.
Related Examples
• “Introduction to Space-Time Adaptive Processing”
10-33
10 Coordinate Systems and Motion Modeling
For a narrowband signal propagating at the speed of light, the one-way Doppler shift in
hertz is:
v
Df = ±
l
where v is the relative radial speed of the target with respect to the transmitter. For a
target approaching the receiver, the Doppler shift is positive. For a target receding from
the transmitter, the Doppler shift is negative.
You can use speed2dop to convert the relative radial speed to the Doppler shift in hertz.
You can use dop2speed to determine the radial speed of a target relative to a receiver
based on the observed Doppler shift.
The one-way Doppler shift is approximately 76.72 Hz. The fact that the target is
approaching the receiver results in a positive Doppler shift.
10-34
Doppler Shift and Pulse-Doppler Processing
The slow-time data are sampled at the pulse repetition frequency (PRF) and therefore
the DFT of the slow-time data for a given range bin yields an estimate of the Doppler
spectrum from [-PRF/2, PRF/2] Hz. Because the slow-time data are complex-valued,
the DFT magnitudes are not necessarily an even function of the Doppler frequency.
This removes the ambiguity between a Doppler shift corresponding to an approaching
(positive Doppler shift), or receding (negative Doppler shift) target. The resolution in the
Doppler domain is PRF/N where N is the number of slow-time samples. You can pad the
spectral estimate of the slow-time data with zeros to interpolate the DFT frequency grid
and improve peak detection, but this does not improve the Doppler resolution.
• Detecting a target in the range dimension (fast-time samples). This gives the range
bin to analyze in the slow-time dimension.
• Computing the DFT of the slow-time samples corresponding to the specified
range bin. Identify significant peaks in the magnitude spectrum and convert the
corresponding Doppler frequencies to speeds.
10-35
10 Coordinate Systems and Motion Modeling
[0;0;0]. The radar consists of a single isotropic antenna element. There is a target with
a non-fluctuating radar cross section (RCS) of 1 square meter located initially at [1000;
1000; 0] and moving with a constant velocity of [-100; -100; 0]. The antenna
operates at a frequency of 1 GHz and illuminates the target with 10 rectangular pulses at
a PRF of 10 kHz.
Define the System objects needed for this example and set their properties. Seed
the random number generator for the phased.ReceiverPreamp object to produce
repeatable results.
hwav = phased.RectangularWaveform('SampleRate',5e6,...
'PulseWidth',6e-7,'OutputFormat','Pulses',...
'NumPulses',1,'PRF',1e4);
htgt = phased.RadarTarget('Model','Nonfluctuating',...
'MeanRCS',1,'OperatingFrequency',1e9);
htgtloc = phased.Platform('InitialPosition',[1000; 1000; 0],...
'Velocity',[-100; -100; 0]);
hant = phased.IsotropicAntennaElement(...
'FrequencyRange',[5e8 5e9]);
htrans = phased.Transmitter('PeakPower',5e3,'Gain',20,...
'InUseOutputPort',true);
htransloc = phased.Platform('InitialPosition',[0;0;0],...
'Velocity',[0;0;0]);
hrad = phased.Radiator('OperatingFrequency',1e9,'Sensor',hant);
hcol = phased.Collector('OperatingFrequency',1e9,'Sensor',hant);
hspace = phased.FreeSpace('SampleRate',hwav.SampleRate,...
'OperatingFrequency',1e9,'TwoWayPropagation',false);
hrx = phased.ReceiverPreamp('Gain',0,'LossFactor',0,...
'SampleRate',5e6,'NoiseFigure',5,...
'EnableInputPort',true,'SeedSource','Property','Seed',1e3);
The following loop transmits ten successive rectangular pulses toward the target, reflects
the pulses off the target, collects the reflected pulses at the receiver, and updates the
target’s position with the specified constant velocity.
NumPulses = 10;
sig = step(hwav); % get waveform
transpos = htransloc.InitialPosition; % get transmitter position
rxsig = zeros(length(sig),NumPulses);
% transmit and receive ten pulses
for n = 1:NumPulses
% update target position
[tgtpos,tgtvel] = step(htgtloc,1/hwav.PRF);
[tgtrng,tgtang] = rangeangle(tgtpos,transpos);
10-36
Doppler Shift and Pulse-Doppler Processing
tpos(n) = tgtrng;
[txsig,txstatus] = step(htrans,sig); % transmit waveform
txsig = step(hrad,txsig,...
tgtang); % radiate waveform toward target
txsig = step(hspace,txsig,transpos,tgtpos,...
[0;0;0],tgtvel); % propagate waveform to target
txsig = step(htgt,txsig); % reflect the signal
% propagate waveform from the target to the transmiter
txsig = step(hspace,txsig,tgtpos,transpos,tgtvel,[0;0;0]);
txsig = step(hcol,txsig,tgtang); % collect signal
rxsig(:,n) = step(hrx,txsig,~txstatus); % receive the signal
end
rxsig contains the echo data in a 500-by-10 matrix where the row dimension contains
the fast-time samples and the column dimension contains the slow-time samples. In
other words, each row in the matrix contains the slow-time samples from a specific range
bin.
Construct a linearly-spaced grid corresponding to the range bins from the fast-time
samples. The range bins extend from 0 meters to the maximum unambiguous range.
prf = hwav.PRF;
fs = hwav.SampleRate;
fasttime = unigrid(0,1/fs,1/prf,'[)');
rangebins = (physconst('LightSpeed')*fasttime)/2;
The next step is to detect range bins which contain targets. In this simple scenario,
no matched filtering or time-varying gain compensation is utilized. See “Doppler
Estimation” for an example using matched filtering and range-dependent gain
compensation to improve the SNR.
In this example, set the false-alarm probability to 1e-9. Use noncoherent integration of
the ten rectangular pulses and determine the corresponding threshold for detection in
white Gaussian noise. Because this scenario contains only one target, take the largest
peak above the threshold. Display the estimated target range.
probfa = 1e-9;
NoiseBandwidth = 5e6/2;
npower = noisepow(NoiseBandwidth,...
hrx.NoiseFigure,hrx.ReferenceTemperature);
thresh = npwgnthresh(probfa,NumPulses,'noncoherent');
thresh = sqrt(npower*db2pow(thresh));
[pks,range_detect] = findpeaks(pulsint(rxsig,'noncoherent'),...
10-37
10 Coordinate Systems and Motion Modeling
'MinPeakHeight',thresh,'SortStr','descend');
range_estimate = rangebins(range_detect(1));
fprintf('Estimated range of the target is %4.2f meters.\n',...
range_estimate);
Extract the slow-time samples corresponding to the range bin containing the detected
target. Compute the power spectral density estimate of the slow-time samples using
periodogram and find the peak frequency. Convert the peak Doppler frequency to a
speed using dop2speed. A positive Doppler shift indicates that the target is approaching
the transmitter. A negative Doppler shift indicates that the target is moving away from
the transmitter.
ts = rxsig(range_detect(1),:).';
[Pxx,F] = periodogram(ts,[],256,prf,'centered');
plot(F,10*log10(Pxx)); grid;
xlabel('Frequency (kHz)');
ylabel('Power (dB)');
title('Periodogram Spectrum Estimate');
[Y,I] = max(Pxx);
lambda = physconst('LightSpeed')/1e9;
tgtspeed = dop2speed(F(I)/2,lambda);
fprintf('Estimated target speed is %3.1f m/sec.\n',tgtspeed);
if F(I)>0
fprintf('The target is approaching the radar.\n');
else
fprintf('The target is moving away from the radar.\n');
end
10-38
Doppler Shift and Pulse-Doppler Processing
The true radial speed of the target is detected within the Doppler resolution and the
range of the target is detected within the range resolution of the radar.
Related Examples
• “Doppler Estimation”
• “Scan Radar Using a Uniform Rectangular Array”
10-39
10-40
11
Using Polarization
11 Using Polarization
Polarized Fields
In this section...
“Introduction to Polarization” on page 11-2
“Linear and Circular Polarization” on page 11-4
“Elliptic Polarization” on page 11-9
“Linear and Circular Polarization Bases” on page 11-13
“Sources of Polarized Fields” on page 11-17
“Scattering Cross-Section Matrix” on page 11-24
“Polarization Loss Due to Field and Receiver Mismatch” on page 11-27
“Polarization Example” on page 11-29
Introduction to Polarization
You can use the Phased Array System Toolbox software to simulate radar systems that
transmit, propagate, reflect, and receive polarized electromagnetic fields. By including
this capability, the toolbox can realistically model the interaction of radar waves with
targets and the environment.
It is a basic property of plane waves in free-space that the directions of the electric and
magnetic field vectors are orthogonal to their direction of propagation. The direction of
propagation of an electromagnetic wave is determined by the Poynting vector
S = E¥ H
In this equation, E represents the electric field and H represents the magnetic field.
The quantity, S, represents the magnitude and direction of the wave’s energy flux.
Maxwell’s equations, when applied to plane waves, produce the result that the electric
and magnetic fields are related by
E = - Zs ¥ H
1
H = s¥E
Z
The vector s, the unit vector in the S direction, represents the direction of propagation
of the wave. The quantity, Z, is the wave impedanceand is a function of the electric
permittivity and the magnetic permeability of medium in which the wave travels.
11-2
Polarized Fields
After manipulating the two equations, you can see that the electric and magnetic fields
are orthogonal to the direction of propagation
E•s = H•s = 0.
This last result proves that there are really only two independent components of the
electric field, labeled Ex and Ey. Similarly, the magnetic field can be expressed in terms
of two independent components. Because of the orthogonality of the fields, the electric
field can be represented in terms of two unit vectors orthogonal to the direction of
propagation.
E = Ex e$ x + Ey e$ y
The unit vectors together with the unit vector in direction of propagation
{e˘ x , e˘ y , s}.
form a right-handed orthonormal triad. Later, these vectors and the coordinates they
define will be related to the coordinates of a specific radar system. In radar systems, it is
common to use the subscripts, H and V, denoting the horizontal and vertical components,
instead of x and y. Because the electric and magnetic fields are determined by each other,
only the properties of the electric field need be consider.
For a radar system, the electric and magnetic field are actually spherical waves, rather
than plane waves. However, in practice, these fields are usually measured in the far
field region or radiation zone of the radar source and are approximately plane waves.
In the far field, the waves are called quasi-plane waves. A point lies in the far field if
its distance, R, from the source satisfies R ≫D2/λ where D is a typical dimension of the
source, whether it is a single antenna or an array of antennas.
Polarization applies to purely sinusoidal signals. The most general expression for a
sinusoidal plane-wave has the form
11-3
11 Using Polarization
do not change with time. The definition of polarization can be broadened to include
narrowband signals, for which the bandwidth is small compared to the center or carrier
frequency of the signal. The amplitude ratio and phases difference vary slowly with time
when compared to the period of the wave and may be thought of as constant over many
oscillations.
You can usually suppress the spatial dependence of the field and write the electric field
vector as
Ey0
Ey = Ex
Ex0
This equation represents a straight line through the origin with positive slope.
Conversely, suppose ≫x = ≫y + π. Then, the tip of the electric field vector follows a straight
line through the origin with negative slope
Ey0
Ey = - Ex
Ex0
These two polarization cases are named linear polarized because the field always
oscillates along a straight line in the orthogonal plane. If Ex0= 0, the field is vertically
polarized, and if Ey0 = 0 the field is horizontally polarized.
A different case occurs when the amplitudes are the same, Ex = Ey, but the phases differ
by ±π/2
Ex = E0 cos(w t + f )
Ey = E0 cos(w t + f ± p / 2) = ∓ E0 sin(wt + f )
11-4
Polarized Fields
By squaring both sides, you can show that the tip of the electric field vector obeys the
equation of a circle
While this equation gives the path the vector takes, it does not tell you in what
direction the electric field vector travels around the circle. Does it rotate clockwise or
counterclockwise? The rotation direction depends upon the sign of π/2 in the phase. You
can see this dependency by examining the motion of the tip of the vector field. Assume
the common phase angle, ≫ = 0. This assumption is permissible because the common
phase only determines starting position of the vector and does not change the shape
of its path. First, look at the +π/2 case for a wave travelling along the s-direction (out
of the page). At t=0, the vector points along the x-axis. One quarter period later, the
vector points along the negative y-axis. After another quarter period, it points along the
negative x-axis.
y
E (t = 3T/4)
E (t = T/2) E (t = 0)
x
E (t = T/4)
11-5
11 Using Polarization
MATLAB uses the IEEE convention to assign the names right-handed or left-handed
polarization to the direction of rotation of the electric vector, rather than clockwise or
counterclockwise. When using this convention, left or right handedness is determined
by pointing your left or right thumb along the direction of propagation of the wave.
Then, align the curve of your fingers to the direction of rotation of the field at a given
point in space. If the rotation follows the curve of your left hand, then the wave is left-
handed polarized. If it follows the curve of your right hand, then the wave is right-
handed polarized. In the preceding scenario, the field is left-handed circularly polarized
(LHCP). The phase difference –π/2 corresponds to right-handed circularly polarized
wave (RHCP). The following figure provides a three-dimensional view of what a LHCP
electromagnetic wave looks like as it moves in the s-direction.
When the terms clockwise or counterclockwise are used they depend upon how you look
at the wave. If you look along the direction of propagation, then the clockwise direction
corresponds to right-handed polarization and counterclockwise corresponds to left-
handed polarization. If you look toward where the wave is coming from, then clockwise
corresponds to left-handed polarization and counterclockwise corresponds to right-
handed polarization.
11-6
Polarized Fields
The figure below summarizes the appearance of linear and circularly polarized fields as
they move towards you along the s-direction.
11-7
11 Using Polarization
y y
Ey Ey
E E
τ
τ
x O
x
O Ex
Ex
Linear polarization with positive slope Linear polarization with negative slope
y y
E E
Ey Ey
x x
O Ex O Ex
11-8
Polarized Fields
Elliptic Polarization
Besides the linear and circular states of polarization, a third type of polarization is
elliptic polarization. Elliptic polarization includes linear and circular polarization as
special cases.
As with linear or circular polarization, you can remove the time dependence to obtain the
locus of points that the tip of the electric field vector travels
2 2
Ê Ex ˆ Ê Ey ˆ Ê E ˆ Ê Ey ˆ
Á ˜ +Á ˜ - 2Á x ˜ ÁÁ ˜ cos f = sin 2 f
Ë Ex 0 ¯ ÁË Ey0 ˜
¯ Ë Ex0 ¯ Ë Ey0 ˜
¯
In this case, φ = φy – φx. This equation represents a tilted two-dimensional ellipse. Its
size and shape are determined by the component amplitudes and phase difference. The
presence of the cross term indicates that the ellipse is tilted. The equation does not, just
as in the circularly polarized case, provide any information about the rotation direction.
For example, the following figure shows the instantaneous state of the electric field but
does not indicate the direction in which the field is rotating.
The size and shape of a two-dimensional ellipse can be defined by three parameters.
These parameters are the lengths of its two axes, the semi-major axis, a, and semi-minor
axis, b, and a tilt angle, τ. The following figure illustrates the three parameters of a tilted
ellipse. You can derive them from the two electric field amplitudes and phase difference.
11-9
11 Using Polarization
Ey0
Ey
E a
b
τ
x
O Ex Ex0
Polarization Ellipse
E = E x 0e
ifx iw t
e
if
( if if
)
e$ x + E y0 e y eiw t e$ y = Ex 0 e x e$ x + Ey0 e y e$ y eiwt
Define the complex polarization ratio as the ratio of the complex amplitudes
Ey0 i( f y -f x ) Ey 0 if
r= e = e
Ex0 Ex0
11-10
Polarized Fields
where ≫ = ≫y – ≫x.
It is useful to introduce the polarization vector. For the complex polarized electric field
above, the polarization vector, P, is obtained by normalizing the electric field
Ex 0 $ Ey0 i ( f y -fx ) $ E Ey 0 if $
P= ex + e e y = x0 e$ x + e ey
Em Em Em Em
The overall size of the polarization ellipse is not important because that can vary as the
wave travels through space, especially through geometric attenuation. What is important
is the shape of the ellipse. Thus, the significant ellipse parameters are the ratio of its axis
dimensions, a/b, called the axial ratio, and the tilt angle, τ. Both of these quantities can
be determined from the ratio of the component amplitudes and the phase difference, or,
equivalently, from the polarization ratio. Another quantity, equivalent to the axial ratio,
is the ellipticity angle, ε.
In the Phased Array System Toolbox software, you can use the polratio function to
convert the complex amplitudes fv=[Ey;Ex] to the polarization ratio.
p = polratio(fv)
Tilt Angle
The tilt angle is defined as the positive (counterclockwise) rotation angle from the x-axis
to the semi-major axis of the ellipse. Because of the symmetry properties of the ellipse,
the tilt angle, τ, needs only be defined in the range –π/2 ≤ τ ≤ π/2. You can find the tilt
angle by determining the rotated coordinate system in which the semi-major and semi-
minor axes align with the rotated coordinate axes. Then, the ellipse equation has no
cross-terms. The solution takes the form
2E x0 E y0
tan 2t = cos f
E x20 - E 2y0
where φ = φy – φx. Notice that you can rewrite this equation strictly in terms of the
amplitude ratio and the phase difference.
After solving for the tilt angle, you can determine the semi-major and semi-minor axis
lengths. Conceptually, you rotate the ellipse clockwise by the tilt angle and measure the
11-11
11 Using Polarization
lengths of the intersections of the ellipse with the x- and y-axes. The point of intersection
with the larger value is the semi-major axis, a, and the one with the smaller value is the
semi-minor axis, b.
The axial ratio is defined as AR = a/b and, by construction, is always greater than or
equal to one. The ellipticity angle is defined by
b
tan e = ∓
a
Ey 0
tan a =
E x0
Both the axial ratio and ellipticity angle are defined from the amplitude ratio and phase
difference and are independent of the overall magnitude of the field.
Rotation Sense
For elliptic polarization, just as with circular polarization, you need another parameter
to completely describe the ellipse. This parameter must provide the rotation sense or
the direction that the tip of the electric (or magnetic vector) moves in time. The rate
of change of the angle that the field vector makes with the x-axis is proportion to –sin
φ where φ is the phase difference. If sin φ is positive, the rate of change is negative,
indicating that the field has left-handed polarization. If sin φ is negative, the rate of
change is positive or right-handed polarization.
The function polellip lets you find the values of the parameters of the polarization
ellipse from either the field component vector fv=[Ey;Ex] or the polarization ratio, p.
fv=[Ey;Ex];
[tau,epsilon,ar,rs] = polellip(fv);
p = polratio(fv);
[tau,epsilon,ar,rs] = polellip(p);
The variables tau, epsilon, ar and rs represent the tilt angle, ellipticity angle, axial
ratio and rotation sense, respectively. Both syntaxes give the same result.
11-12
Polarized Fields
This table summaries several different common polarization states and the values of the
amplitudes, phases, and polarization ratio that produce them:
E = Re[ E0 (e x ∓ ie y ) ei (w t+f ) ]
In this equation, the positive sign is for the LHCP field and the negative sign is for the
RHCP field. These two special combinations can be given a new name. Define a new basis
vector set, called the circular basis set
1
er = ( e x - ie y )
2
1
el = ( e x + ie y )
2
11-13
11 Using Polarization
You can express any polarized field in terms of the circular basis set instead of the linear
basis set. Conversely, you can also write the linear polarization basis in terms of the
circular polarization basis
1
ex = (e r + el )
2
1
ey = (e r - el )
2i
Any general elliptic field can be written as a combination of circular basis vectors
E = El e l + Er er
Jones Vector
The polarized field is orthogonal to the wave’s direction of propagation. Thus, the field
can be completely specified by the two complex components of the electric field vector in
the plane of polarization. The formulation of a polarized wave in terms of two-component
vectors is called the Jones vector formulation. The Jones vector formulation can be
expressed in either a linear basis or a circular basis or any basis. This table shows the
representation of common polarizations in a linear basis and circular basis.
Common Polarizations Jones Vector in Linear Basis Jones Vector in Circular Basis
Vertical [0;1] 1/sqrt(2)*[-1;1]
Horizontal [1;0] 1/sqrt(2)*[1;1]
45° Linear 1/sqrt(2)*[1;1] 1/sqrt(2)*[1-1i;1+1i]
135° Linear 1/sqrt(2)*[1;-1] 1/sqrt(2)*[1+1i;1-1i]
Right Circular 1/sqrt(2)*[1;-1i] [0;1]
Left Circular 1/sqrt(2)*[1;1i] [1;0]
11-14
Polarized Fields
The measurable intensities are the Stokes parameters, S0, S1, S2, and S3. The first
Stokes parameter, S0, describes the total intensity of the field. The second parameter,
S1, describes the preponderance of linear horizontally polarized intensity over linear
vertically polarized intensity. The third parameter, S2, describes the preponderance
of linearly +45° polarized intensity over linearly 135° polarized intensity. Finally, S3
describes the preponderance of right circularly polarized intensity over left circularly
polarized intensity. The Stokes parameters are defined as
S0 = E 2x0 + E 2y 0
S1 = E 2x0 - E 2y 0
S2 = 2 Ex 0 E y 0 cos f
S3 = 2 Ex 0 E y 0 sinf
For completely polarized fields, you can show by time averaging the polarization ellipse
equation that
For partially polarized fields, in contrast, the Stokes parameters satisfy the inequality
The Stokes parameters are related to the tilt and ellipticity angles, τ and ε
S1 = S0 cos 2t cos 2e
S2 = S0 sin 2t cos 2e
S3 = S0 sin 2e
and inversely by
S2
tan 2t =
S1
S3
sin 2e =
S0
11-15
11 Using Polarization
After you measure the Stokes’ parameters, the shape of the ellipse is completely
determined by the preceding equations.
The two-dimensional Poincaré sphere can help you visualize the state of a polarized
wave. Any point on or in the sphere represents a state of polarization determined by the
four Stokes parameters, S0, S1, S2, and S3. On the Poincaré sphere, the angle from the S1-
S2 plane to a point on the sphere is twice the ellipticity angle, ε. The angle from the S1-
axis to the projection of the point into the S1-S2 plane is twice the tilt angle, τ.
S3
S0
2ϵ
S2
2τ
S1
As an example, solve for the Stokes parameters of a RHCP field, fv=[1,-i], using the
stokes function.
11-16
Polarized Fields
S = stokes(fv)
S =
2
0
0
-2
For transmitting antennas, the shape of the antenna is chosen to enhance the power
projected into a given direction. For receiving antennas, you choose the shape of the
antenna to enhance the power received from a particular direction. Often, many
transmitting antennas or receiving antennas are formed into an array. Arrays increase
the transmitted power for a transmitting system or the sensitivity for a receiving system.
They improve directivity over a single antenna.
Each antenna or array has an associated local Cartesian coordinate system (x,y,z)
as shown in the following figure. See “Global and Local Coordinate Systems” for
more information. The local coordinate system can also be represented by a spherical
coordinate system using azimuth, elevation and range coordinates, az, el, r, or alternately
written, (φ,θ,r), as shown. At each point in the far field, you can create a set of unit
spherical basis vectors, {e$ H , e$V , r$ } . The basis vectors are aligned with the (φ,θ,r)
directions, respectively. In the far field, the electric field is orthogonal to the unit vector
11-17
11 Using Polarization
r̂ . The components of a polarized field with respect to this basis, (EH,EV), are called the
horizontal and vertical components of the polarized field. In radar, it is common to use
(H,V) instead of (x,y) to denote the components of a polarized field. In the far field, the
polarized electric field takes the form
eikr eikr
E = F(f ,q ) = ( FH (f ,q ) eH + FV (f ,q )eV )
r r
In this equation, the quantity F(φ,θ) is called the vector radiation pattern of the source
and contains the angular dependence of the field in the far-field region.
êV
F(φ,θ)
êΗ
^r
r
Radar Coordinate System
θ, el
y
φ, az
The simplest antenna is the dipole antenna which consist of a split length of wire coupled
at the middle to a coaxial cable. The simplest dipole, from a mathematical perspective,
is the Hertzian dipole, in which the length of wire is much shorter than a wavelength. A
diagram of the short dipole antenna of length L appears in the next figure. This antenna
is fed by a coaxial feed which splits into two equal length wires of length L/2. The
current, I, moves along the z-axis and is assumed to be the same at all points in the wire.
11-18
Polarized Fields
L/2
EV
EH
r
el
y
az
x
-L/2
Er = 0
EH = 0
iZ 0 IL e-ikr
EV = - cos el
2l r
The next figure shows how the vertical and horizontal polarization components of the
field depend on the elevation angle for all values of azimuth angle because the field is
axially symmetric. The horizontal component vanishes.
11-19
11 Using Polarization
The crossed dipole antenna comprises two identical but orthogonal short dipole antennas
which are phased 90° apart. A diagram of the crossed dipole antenna appears in the
following figure. You use this antenna to generate circularly polarized radiation. The
11-20
Polarized Fields
Er = 0
iZ 0 IL e -ikr
EH = - cos az
2l r
iZ 0 IL e-ikr
EV = (sin el sin az + i cos el)
2l r
The polarization ratio EV/EH when evaluated along the x-axis is just –i which means that
the polarization is exactly RHCP along the x-axis. It is predominantly RHCP when the
observation point is close to the x-axis. Away from the x-axis, the field is a mixture of
LHCP and RHCP polarizations. Along the –x-axis, the field is LHCP polarized. The figure
illustrates, for a point near the x, that the field is primarily RHCP.
11-21
11 Using Polarization
L/2
-L/2 L/2
y
el
EL
-L/2
az
You can see in the next figure how the circular polarization changes from pure RHCP at
0° azimuth angle to LHCP at 180° azimuth angle, both at 0° elevation.
11-22
Polarized Fields
Besides modeling antennas, the toolbox models several kinds of antenna arrays:
11-23
11 Using Polarization
You can create polarized fields from arrays by using polarized antenna elements as a
value of the Elements property of an array System object.
In general, the scattering cross-section matrix depends upon the angles that the incident
and scattered fields make with the object. When the incident field is scattered back to the
transmitting antenna or, backscattered, the scattering matrix is symmetric.
Polarization Signature
To understand how the scattered wave depends upon the polarization of the incident
wave, you need to examine all possible scattered field polarizations for each incident
polarization. Because this amount of data is difficult to visualize, consider two cases:
• The scattered polarization has the same polarization as the incident field
(copolarization)
11-24
Polarized Fields
• The scattered polarization has orthogonal polarization to the incident field (cross-
polarization)
You can represent the incident polarizations in terms of the tilt angle-ellipticity angle
pair (t ,e ) . Every unit incident polarization vector can be expressed as
* È E( inc) ˘
P ( co) = È E(Hinc) EV(inc) ˘ S Í H ˙
Î ˚ Í E( inc) ˙
Î V ˚
where []* denotes complex conjugation. For the cross-polarization signature, compute
* È E( inc) ˘
P ( cross) = È E(Hinc) ^ EV( inc) ^ ˘ S Í H ˙
Î ˚ Í E( inc) ˙
Î V ˚
You can compute both the copolarization and cross polarization signatures using the
polsignature function. This function returns the absolute value of the scattered
power (normalized by its maximum value). The next example shows how to plot the
copolarization signature for the RCSM matrix
È 1˘
Í 2i 2˙
S=Í ˙
Í1 i˙
ÍÎ 2 ˙˚
for all possible incident polarizations. The range of values of the ellipticity angle and tilt
span the entire possible range of polarizations.
11-25
11 Using Polarization
11-26
Polarized Fields
tilt = [-90:90];
polsignature(rscmat,'x',el,tilt);
11-27
11 Using Polarization
• The polarization loss is computed from the projection (or dot product) of the
transmitted field’s electric field vector onto the receiver polarization vector.
• Loss occurs when there is a mismatch in direction of the two vectors, not in their
magnitudes.
• The polarization loss factor describes the fraction of incident power that has the
correct polarization for reception.
Using the transmitter’s spherical basis at the receiver’s position, you can represent the
incident electric field, (EiH, EiV), by
You can represent the receiver’s polarization vector, (PH, PV), in the receiver’s local
spherical basis by:
P = PH eˆ ¢H + PV eˆ ¢V
The next figure shows the construction of the transmitter and receiver spherical basis
vectors.
z'
az
x Transmitter Coordinate System
11-28
Polarized Fields
|Ei ◊ P |2
r=
2
|Ei || P|2
and varies between 0 and 1. Because the vectors are defined with respect to different
coordinate systems, they must be converted to the global coordinate system to form the
projection. The toolbox function polloss computes the polarization mismatch between
an incident field and a polarized antenna.
To achieve maximum output power from a receiving antenna, the matched antenna
polarization vector must be the complex conjugate of the incoming field’s polarization
vector. As an example, if the incoming field is RHCP, with polarization vector given by
1
er = ( e x - ie y ) , the optimum receiver antenna polarization is LHCP. The introduction
2
of the complex conjugate is needed because field polarizations are described with respect
to its direction of propagation, whereas the polarization of a receive antenna is usually
specified in terms of the direction of propagation towards the antenna. The complex
conjugate corrects for the opposite sense of polarization when receiving.
Polarization Example
This example models a tracking radar based on a 31-by-31 (961-element) uniform
rectangular array (URA). The radar is designed to follow a moving target. At each
11-29
11 Using Polarization
time instant, the radar points in the known direction of the target. The basic radar
requirements are the probability of detection, pd, the probability of false alarm, pfa, the
maximum unambiguous range, max_range and the range resolution, range_res (all
distance units are in meters). The range_gate parameter limits the region of interest
to a range smaller than the maximum range. The operating frequency is set in fc. The
simulation lasts for numpulses pulses.
pd = 0.9; % Probability of detection
pfa = 1e-6; % Probability of false alarm
max_range = 1500*1000; % Maximum unambiguous range
range_res = 50.0; % Range resolution
rangegate = 5*1000; % Assume all objects are in this range
numpulses = 200; % Number of pulses to integrate
fc = 8e9; % Center frequency of pulse
c = physconst('LightSpeed');
tmax = 2*rangegate/c; % Time of echo from object at rangegate
Set the pulse repetition interval, PRI, and pulse repetition frequency, PRF, from the
maximum unambiguous range.
PRI = 2*max_range/c;
PRF = 1/PRI;
11-30
Polarized Fields
element oriented along the z-axis. The frequency response of the element is chosen to lie
in the range of 5-10 gigahertz.
sSD = phased.ShortDipoleAntennaElement(...
'FrequencyRange',[5e9,10e9],'AxisDirection','Z');
Define a 31-by-31 Taylor tapered uniform rectangular array using the phased.URA
System object. Set the size of the array using the number of rows, numRows, and the
number of columns, numCols. The distance between elements, d, is slightly smaller
than one-half the wavelength, lambda. Compute the array taper, tw, using separate
Taylor windows for the row and column directions. Obtain the Taylor weights using
the taylorwin function. Plot the 3-D array response using the array phased.URA/
plotResponse method.
numCols = 31;
numRows = 31;
lambda = c/fc;
d = 0.9*lambda/2; % Nominal spacing
wc = taylorwin(numCols);
wr = taylorwin(numRows);
tw = wr*wc';
sArray = phased.URA('Element',sSD,'Size',[numCols,numRows],...
'ElementSpacing',[d,d],'Taper',tw);
plotResponse(sArray,fc,c,'Format','Polar','Polarization','V',...
'RespCut','3D');
11-31
11 Using Polarization
Next, set the properties of the radar platform in the phased.Platform System
object. The radar is assumed to be stationary and positioned at the origin of the global
coordinate system. Set the Velocity property to [0,0,0] and the InitialPosition
property to [0,0,0]. Set the OrientationAxes property to the identity matrix to align
the radar platform coordinate axes with the global coordinate system.
11-32
Polarized Fields
'OrientationAxes',radarPlatformAxes);
Estimate the peak power used in the phased.Transmitter System object to calculate
the desired radiated power levels. The transmitted peak power is the power required
to achieve a minimum-detection SNR, snr_min. You can determine the minimum SNR
from the probability of detection, pd, and the probability of false alarm, pfa, using the
albersheim function. Then, compute the peak power from the radar equation using
the radareqpow function. Among the inputs to this function are the overall signal gain,
which is the sum of the transmitting element gain, TransmitterGain and the array
gain, AG. Another input is the maximum detection range, rangegate. Finally, you need
to supply a target cross-section value, tgt_rcs. A scalar radar cross section is used in
this code section as an approximation even though the full polarization computation later
uses a 2-by-2 radar cross section scattering matrix.
11-33
11 Using Polarization
Create a rotating target object and a moving target platform. The rotating target is
represented later as an angle-dependent scattering matrix.
targetSpeed = 1000; % m/s
targetVec = [-1;1;0]/sqrt(2);
sTarget = phased.RadarTarget(...
'EnablePolarization',true,...
'Mode','Monostatic',...
'ScatteringMatrixSource','Input port',...
'OperatingFrequency',fc);
targetPlatformAxes = [1 0 0;0 1 0;0 0 1];
targetRotRate = 45; % degrees per sec
sTargetPlatform = phased.Platform(...
'InitialPosition',[3500.0; 0; 0],...
'Velocity', targetSpeed*targetVec,...
'OrientationAxes',targetPlatformAxes);
11-34
Polarized Fields
'PropagationSpeed',c,...
'IncludeElementResponse',false);
% Create the receiving beamformer
sBF = phased.PhaseShiftBeamformer('SensorArray',sArray,...
'OperatingFrequency',fc,'PropagationSpeed',c,...
'DirectionSource','Input port');
% Define free space propagation channel
sFS = phased.FreeSpace(...
'SampleRate',fs,...
'TwoWayPropagation',true,...
'OperatingFrequency',fc);
% Define a receiver with receiver noise
sRX = phased.ReceiverPreamp('Gain',20,...
'LossFactor',0,...
'NoiseFigure',1,...
'ReferenceTemperature',290,...
'SampleRate',fs,...
'EnableInputPort',true,...
'PhaseNoiseInputPort',false,...
'SeedSource','Auto');
Allocate MATLAB arrays to store the processing results for later plotting.
sig_max_V = zeros(1,numpulses);
sig_max_H = zeros(1,numpulses);
tm_V = zeros(1,numpulses);
tm_H = zeros(1,numpulses);
After all the System objects are created, loop over the number of pulses to create the
reflected signals. Perform all the processing by invoking the step method for each
System object.
maxsamp = ceil(tmax*fs);
fast_time_grid = [0:(maxsamp-1)]/fs;
rotangle = 0.0;
for m = 1:numpulses
x = step(sWav); % Generate pulse
% Capture only samples within range gated
x = x(1:maxsamp);
[s, tx_status] = step(sTX,x); % Create transmitted pulse
% Move the radar platform and target platform.
[radarPos,radarVel] = step(sRadarPlatform,1/PRF);
[targetPos,targetVel] = step(sTargetPlatform,1/PRF);
% Compute the known target angle
[targetRng,targetAng] = rangeangle(targetPos,...
11-35
11 Using Polarization
radarPos,...
radarPlatformAxes);
% Compute the radar angle with respect to the target axes.
[radarRng,radarAng] = rangeangle(radarPos,...
targetPos,...
targetPlatformAxes);
% Calculate the steering vector designed to track the target
sv = step(sSV,fc,targetAng);
% Radiate the polarized signal toward the targat
tsig1 = step(sRadiator,...
s,...
targetAng,...
radarPlatformAxes,...
conj(sv));
% Compute the two-way propagation loss (4*pi*R/lambda)^2
tsig2 = step(sFS,...
tsig1,...
radarPos,...
targetPos,...
radarVel,...
targetVel);
% Create a very simple model of a changing scattering matrix
scatteringMatrix = [cosd(rotangle),0.5*sind(rotangle);...
0.5*sind(rotangle),cosd(rotangle)];
rsig1 = step(sTarget,...
tsig2,...
radarAng,...
targetPlatformAxes,...
scatteringMatrix); % Reflect off target
% Collect the vertical component of the radiation.
rsig3V = step(sCollector,...
rsig1,...
targetAng,...
radarPlatformAxes);
% Collect the horizontal component of the radiation. This
% second collector is rotated around the x-axis to be more
% sensitive to horizontal polarization
rsig3H = step(sCollector2,...
rsig1,...
targetAng,...
rotx(90)*radarPlatformAxes);
% Add receiver noise to both sets of signals
rsig4V = step(sRX,rsig3V,~(tx_status>0)); % Receive signal
rsig4H = step(sRX,rsig3H,~(tx_status>0)); % Receive signal
11-36
Polarized Fields
Plot the vertical and horizontal polarization for each pulse as a function of time.
figure(2);
plot(tm_V,sig_max_V,'.'); hold on;
plot(tm_H,sig_max_H,'r.'); hold off;
xlabel('Time (sec)')
ylabel('Amplitude');
title('Vertical and Horizontal Polarization Components');
legend('Vertical','Horizontal');
grid on;
11-37
11 Using Polarization
11-38
12
In radar and sonar applications, the interactions between fields and targets take place in
the far-field region, often called the Fraunhofer region. The far-field region is defined as
the region for which
r≫λ2/L
where L represents the largest dimension of the source. In the far-field region, the fields
take a special form: they can be written as the product of a function of direction (such
as azimuth and elevation angles) and a geometric fall-off function, 1/r. It is the angular
function that is called the radiation pattern, response pattern, or simply pattern.
The element field response or element field pattern represents the angular distribution of
the electromagnetic field create by an antenna, E(θ,φ), or the scalar acoustic field, p(θ,φ),
12-2
Element and Array Radiation and Response Patterns
e-ikr
Af (q ,f )
r
where A is a nominal field amplitude and f(θ,φ) is the normalized field pattern
(normalized to unity). Because the field patterns are evaluated at some reference
distance from the source, the fields returned by the element’s step method are
represented simply as A f(θ,φ). You can display the nominal element field pattern by
invoking the element's plotResponse method, choosing 'Units' parameter value as
'mag' and setting the 'NormalizeResponse' parameter to false
plotResponse(elem,'NormalizeResponse', false,'Unit','mag');
You can view the normalized field pattern by setting the 'NormalizeResponse'
parameter value to true. For example, if EH(θ,φ) is the horizontal component of the
complex electromagnetic field, its normalized field pattern is given by |EH(θ,φ)|/EH,max|.
plotResponse(elem,'Polarization','H','NormalizeResponse', true,'Unit','mag');
The element power response (or element power radiation pattern) is defined as the angular
distribution of the radiant intensity in the far field, Urad(θ,φ). When the elements are
used for reception, the patterns are interpreted as the sensitivity of the element to
radiation arriving from direction (θ,φ) and the power pattern represents the output
voltage power of the element as a function of wave arrival direction.
Physically, the radiant intensity for the electromagnetic field produced by an antenna
element is given by
r2
U rad (q , f) =
2 Z0
(| EH |2 + | EV |2 )
where Z0 is the characteristic impedance of free space. The radiant intensity of an
acoustic field is given by
12-3
12 Antenna and Array Definitions
r2
U rad (q , f) = | p|2
2Z
where Z is the characteristic impedance of the acoustic medium. For the fields produced
by the Phased Array System Toolbox element System objects, the radial dependence,
the impedances and field magnitudes are all collected in the nominal field amplitudes
defined above. Then the radiant intensity can generally be written
U rad (q , f) =| Af (q , f)|2
The radiant intensity pattern is the quantity returned by the elements plotResponse
method when the 'NormalizeResponse' parameter is set to false and the 'Unit'
parameter is set to 'pow' (or 'db' for decibels).
plotResponse(elem,'NormalizeResponse',false,'Unit','pow');
The normalized power pattern is defined as the radiant intensity divided by its maximum
value
Urad (q ,f)
U norm (q ,f ) = =| f (q ,f )|2
U rad, max
plotResponse(elem,'NormalizeResponse',true,'Unit','pow');
Element directivity
iso Ptotal
U rad (q , f) =
4p
12-4
Element and Array Radiation and Response Patterns
Urad (q ,f ) U rad (q , f)
D(q ,f ) = = 4p
iso Ptotal
Urad
By this definition, the integral of the directivity over a sphere surrounding the element is
exactly 4π. Directivity is related to the effective beamwidth of an element. Start with an
ideal antenna that has a uniform radiation field over a small solid angle (its beamwidth),
ΔΩ, in a particular direction, and zero outside that angle. The directivity is
Urad (q ,f ) 4p
D(q ,f ) = 4p =
Ptotal DW
The radiant intensity can be expressed in terms of the directivity and the total power
1
U rad (q , f) = D(q ,f ) Ptotal
4p
3
D(q ,f ) = cos2 q
2
Often, the largest value of D(θ,φ) is specified as an antenna operating parameter. The
direction in which D(θ,φ) is largest is the direction of maximum power radiation. This
direction is often called the boresight direction. In some of the literature, the maximum
value itself is called the directivity, reserving the phrase directive gain for what is called
here directivity. For the short-dipole antenna, the maximum value of directivity occurs
at θ = 0, independent of φ, and attains a value of 3/2. The concept of directivity applies
to receiving antennas as well. It describes the output power as a function of the arrival
direction of a plane wave impinging upon the antenna. By reciprocity, the directivity of
a receiving antenna is the same as that for a transmitting antenna. A quantity closely
related to directivity is element gain. The definition of directivity assumes that all the
power fed to the element is radiated to space. In reality, system losses reduce the radiant
intensity by some factor, the element efficiency, η. The term Ptotal becomes the power
12-5
12 Antenna and Array Definitions
supplied to the antenna and Prad becomes the power actually radiated into space. Then,
Prad = ηPtotal. The element gain is defined by
Urad (q ,f ) U (q , f)
G (q , f) = 4p = 4ph rad = h D(q ,f )
Ptotal Prad
and represents the power radiated away from the element compared to the total power
supplied to the element.
Using the element’s plotResponse method, you can plot the directivity of an element by
setting the 'Unit' parameter to 'dbi',
plotResponse(elem,'Unit','dbi');
When individual antenna elements are aggregated into arrays of elements, new response/
radiation patterns are created which depend upon both the element patterns and the
geometry of the array. These patterns are called beampatterns to reflect the fact that
the pattern may be constructed to have a very narrow angular distribution, i.e. a beam.
This term is used for an array in transmitting or receiving modes. Most often, but not
always, the array consists of identical antennas. The identical antenna case is interesting
because it lets us partition the radiation pattern into two components: one component
describes the element radiation pattern and the second describes the array radiation
pattern.
For transmitting arrays, the voltage driving the elements may be phase-adjusted to
allow the maximum radiant intensity to be transmitted in a particular direction. For
receiving arrays, the arriving signals may be phase adjusted to maximize the sensitivity
in a particular direction.
Start with a simple model of the radiation field produced by a single antenna which is
given by
12-6
Element and Array Radiation and Response Patterns
e-ikr
y(q ,f , r) = Af (q ,f )
r
where A is the field amplitude and f((θ,φ) is the normalized element field pattern. This
field may represent any of the components of the electric field, a scalar field, or an
acoustic field. For an array of identical elements, the output of the array is the weighted
sum of the individual elements, using the complex weights, wm
M -1 - ikrm
e
z(q ,f , r) = A Â wm* f (q ,f ) rm
m= 0
where rm is the distance from the mth element source point to the field point. In the far-
field region, this equation takes the form
M -1
e-ikr
z(q ,f , r) = A f (q ,f ) Â w*m e-iku •x m
r m= 0
where xm are the vector positions of the array elements with respect to the array origin.
u is the unit vector from the array origin to the field point. This equation can be written
compactly is the form
e-ikr
z(q ,f , r) = A f (q ,f ) w H s
r
The term wHs is called the array factor, Farray(θ,φ). The vector s is the steering vector (or
array manifold vector) for directions of propagation for transmit arrays or directions of
arrival for receiving arrays
The total array pattern consists of an amplitude term, an element pattern, f(θ,φ), and an
array factor, Farray(θ,φ). The total angular behavior of the array pattern, B(θ,φ), is called
the beampattern of the array
12-7
12 Antenna and Array Definitions
When evaluated at the reference distance, the array field pattern has the form
Af (q ,f )w H s = Af (q ,f ) Farray (q ,f ) = AB(q ,f )
For the conventional beamformer, the weights are chosen to maximize the power
transmitted towards a particular direction, or in the case of receiving arrays, to maximize
the response of the array for a particular arrival direction. If u0 is the desired pointing
direction, then the weights which maximize the power and response in this direction
have the general form
w =|wm | e-iku0 •x m
M -1
Farray (q ,f ) = Â |wm |e -ik(u - u )•x
0 m
m =0
12-8
Element and Array Radiation and Response Patterns
Array directivity
Array directivity is defined the same way as element directivity: the radiant intensity
in a specific direction divided by the isotropic radiant intensity. The isotropic radiant
intensity is the array’s total radiated power divided by 4π. In terms of the arrays weights
and steering vectors, the directivity can be written as
| Af (q ,f ) w H s|2
D(q ,f ) = 4p
Ptotal
where Ptotal is the total radiated power from the array. In a discrete implementation, the
total radiated power can be computed by summing intensity values over a uniform grid of
angles that covers the full sphere surrounding the array
M -1 N -1
2p 2
Ptotal = Â Â |Af (q m ,fn ) w H s(q m ,fn )|2 cos qm
MN m =0 n = 0
where M is the number of elevation grid points and N is the number of azimuth grid
points.
Because the radiant intensity is proportional to the beampattern, B(θ,φ), the directivity
can also be written in terms of the beampattern
| B(q ,f )|2
D(q ,f ) = 4p
Ú|B(q ,f )|
2
cos q dq df
You can plot the directivity of an array by setting the 'Unit' parameter of the
plotResponse methods to 'dbi',
plotResponse(array,'Unit','dbi');
Array gain
In the Phased Array System Toolbox, array gain is defined to be the array SNR gain.
Array gain measures the improvement in SNR of a receiving array over the SNR for a
single element. Because an array is a spatial filter, the array SNR depends upon the
12-9
12 Antenna and Array Definitions
spatial properties of the noise field. When the noise is spatially isotropic, the array gain
takes a simple form
In addition, for an array with uniform weights, the array gain for an N-element array
has a maximum value at boresight of N, (or 10logN in db).
12-10
13
Code Generation
Code Generation
In this section...
“Code Generation Use and Benefits” on page 13-2
“Limitations Specific to Phased Array System Toolbox” on page 13-3
“General Limitations” on page 13-6
“Limitations for System Objects that Require Dynamic Memory Allocation” on page
13-11
In general, the code you generate using the toolbox is portable ANSI® C code. In order
to use code generation, you need a MATLAB Coder license. Using Phased Array System
Toolbox software requires licenses for both the DSP System Toolbox™ and the Signal
Processing Toolbox™. See the “Getting Started with MATLAB Coder” page for more
information.
Within your code, you can run specific commands either as generated C code or by
running using the MATLAB engine. In cases where an isolated command does not yet
have code generation support, you can use the coder.extrinsic command to embed
the command in your code. This means that the generated code reenters the MATLAB
environment when it needs to run that particular command. This also useful if you wish
to embed certain commands that cannot generate code (such as plotting functions).
13-2
Code Generation
The simplest way to generate MEX-files from your MATLAB code is by using the
codegen function at the command line. Often, generating a MEX-files involves nothing
more than invoking the coder command on one of your existing functions. For example,
if you have an existing function, myfunction.m, you can type the commands at the
command line to compile and run the MEX function. codegen adds a platform-specific
extension to this name. In this case, the “mex” suffix is added.
codegen myfunction.m
myfunction_mex;
You can generate standalone executables that run independently of the MATLAB
environment. You can do this by creating a MATLAB Coder project inside the MATLAB
Coder Integrated Development Environment (IDE). Alternatively, you can issue the
codegen command in the command line environment with appropriate configuration
parameters. To create a standalone executable, you must write your own main.c or
main.cpp function. See “C/C++ Code Generation” for more information.
Before using codegen to compile your code, you must set up your C/C++ compiler. For
32-bit Windows platforms, MathWorks® supplies a default compiler with MATLAB. If
your installation does not include a default compiler, you can supply your own compiler.
For the current list of supported compilers, see Supported and Compatible Compilers
on the MathWorks Web site. Install a compiler that is suitable for your platform. Then,
read “Setting Up the C or C++ Compiler”. After installation, at the MATLAB command
prompt, run mex -setup. You can then use the codegen function to compile your code.
Almost all Phased Array System Toolbox functions and System objects are supported for
code generation. For a list of supported functions and System objects, see “Functions and
System Objects Supported for C/C++ Code Generation” on page 13-18.
• Passing arguments with variable-sized dimensions into any Phased Array System
Toolbox function or System object step method is not supported.
13-3
13 Code Generation
• When you employ antennas and arrays that produce polarized fields, the
EnablePolarization parameter for the phased.Collector, phased.Radiator, and
phased.WidebandCollector, phased.RadarTarget, phased.ArrayResponse,
and phased.SteeringVector System objects must be set to true. This requirement
differs from regular MATLAB usage where you can set EnablePolarization property
to false even when polarization is enabled. For example, this code uses a polarized
antenna, which requires that EnablePolarization property of the phased.Radiator
System object be set to true.
function [y] = codegen_radiator()
sSD = phased.ShortDipoleAntennaElement(...
'FrequencyRange',[100e6,600e6],'AxisDirection','Y');
c = physconst('LightSpeed');
fc = 200e6;
lambda = c/fc;
d = lambda/2;
sURA = phased.URA('Element',sSD,...
'Size',[3,3],...
'ElementSpacing',[d,d]);
sRad = phased.Radiator('Sensor',sURA,...
'OperatingFrequency',150e6,...
'CombineRadiatedSignals',true,...
'EnablePolarization',true);
x = [1;2;1];
radiatingAngle = [10;0]; % One angle for one antenna
y = step(sRad,x,radiatingAngle,eye(3,3));
• Visualization methods for Phased Array System Toolbox methods such
plotResponse and viewArray are not supported.
• When a System object contains another System object as a property value, you must
set the contained System object in the constructor. You cannot use Object.Property
notation to set the property. For example
sSD = phased.ShortDipoleAntennaElement(...
'FrequencyRange',[100e6,600e6],'AxisDirection','Y');
sURA = phased.URA('Element',sSD,...
'Size',[3,3],...
'ElementSpacing',[0.75,0.75]);
13-4
Code Generation
'ElementSpacing',[0.75,0.75]);
sURA.Element = sSD;
is not.
• A list of the limitations on Phased Array System Toolbox functions and System
objects is presented here:
13-5
13 Code Generation
General Limitations
Code Generation has some general limitations not specifically related to the Phased
Array System Toolbox software. For a more complete discussion, see “System Objects in
MATLAB Code Generation”.
the following error message is produced: "A nontunable property may only be
assigned once."
• You cannot pass a System object to any method or function that you made extrinsic
using coder.extrinsic.
• You cannot load a MAT-file using coder.load when it contains a System object. For
example, if you construct a System object in the MATLAB environment and save it to
a MAT-file
sSD = phased.ShortDipoleAntennaElement(...
'FrequencyRange',[0.9e8,2e9],'AxisDirection','Y');
save x.mat sSD;
clear sSD;
then you cannot load the System object in your compiled MEX-file:
function codegen_load1()
13-6
Code Generation
W = coder.load('x.mat');
sSD = W.sSD;
The compilation
codegen codegen_load1
will produced an error message: ‘Found unsupported class for
variable using function 'coder.load'. MATLAB class
'phased.ShortDipoleAntennaElement' found at 'W.sSD' is
unsupported.’
To avoid this problem, you can save the object's properties to a MAT-file, then, use
coder.load to load the object properties and re-create the object. For example,
create and save a System object’s properties in the MATLAB environment
sSD = phased.ShortDipoleAntennaElement(...
'FrequencyRange',[0.9e8,2e9],'AxisDirection','Y');
FrequencyRange = sSD.FrequencyRange;
AxisDirection = sSD.AxisDirection;
save x.mat FrequencyRange AxisDirection;
Then, write a function codegen_load2 to load the properties and create a System
object.
function codegen_load2()
W = coder.load('x.mat');
sSD = phased.ShortDipoleAntennaElement(...
'FrequencyRange',W.FrequencyRange,...
'AxisDirection',W.AxisDirection);
Then, issue the commands to create and execute the MEX-file, codegen_load2_mex.
codegen codegen_load2;
codegen_load2_mex
• Nontunable properties must be constant. A constant is a value that can be evaluated
at compile-time. System objects properties are either tunable or nontunable. You can
change tunable properties even if the object is locked. Unless otherwise specified,
System object properties are nontunable. Refer to the object's reference page to
determine whether an individual property is tunable or not. If you try to set a
nontunable System object property and the compiler determines that it is not
constant, you will get an error. For example, the phased.URA System object has a
nontunable property, ElementSpacing, which sets the distance between elements.
You may want to create an array that is tuned to a frequency. You cannot pass in the
frequency as an input argument because the frequency must be a constant.
13-7
13 Code Generation
fc = 200e6;
codegen codegen_const1 -args {fc}
the compiler responds that the value of the 'ElementSpacing' property, d, is not
constant and generates the error message: "Failed to compute constant value
for nontunable property 'ElementSpacing'. In code generation,
nontunable properties can only be assigned constant values." It is
not constant because it depends upon a non-constant variable, fc.
codegen codegen_const2
• In certain cases, the compiler cannot determine the values of nontunable properties
at compile time or the code may not even compile. Consider the following example
13-8
Code Generation
that reads in the x,y,z-coordinates of a 5-element array from a file and then, creates
a conformal array System object. The text file, elempos.txt, contains the element
coordinates
function y = collectWave(angle)
elPos = calcElPos;
cArr = phased.ConformalArray('ElementPosition',elPos);
y = collectPlaneWave(cArr,randn(4,2),angle,1e8);
end
function y = collectWave1(angle)
coder.extrinsic('calcElPos')
elPos = coder.const(calcElPos);
cArr = phased.ConformalArray('ElementPosition',elPos);
y = collectPlaneWave(cArr,randn(4,2),angle,1e8);
end
The file calcElPos.m loads the element positions from the text file
13-9
13 Code Generation
fid = fopen('elempos.txt','r');
el = textscan(fid, '%f');
n = length(el{1});
nelem = n/3;
fclose(fid);
elPos = reshape(el{1},nelem,3).';
Only the collectWave1.m file is compiled with codegen. Compiling and running
function calcElPos2
fid = fopen('elempos.txt');
el = textscan(fid, '%f');
fclose(fid);
elPos = reshape(el{1},[],3).';
save('positions', 'elPos');
end
The file collectWave2.m loads the coordinate positions and creates the conformal
array object
function y = collectWave2(angle)
var = coder.load('positions');
cArr = phased.ConformalArray('ElementPosition',var.elPos);
y = collectPlaneWave(cArr,randn(4,2),angle,1e8);
end
Only the collectWave2.m file is compiled with codegen. Compiling and running
collectWave2.m
13-10
Code Generation
13-11
13 Code Generation
Run codegen at the command line to generate the mex function, EstimateDOA_mex,
and then run the mex function:
codegen EstimateDOA.m
EstimateDOA_mex
13-12
Generate MEX Function to Estimate Directions of Arrival
az =
10.0036 45.0030
The program contains a fixed value for the noise variance. If you wanted to reuse the
same code for different noise levels, you can pass the noise variance as an argument into
the function. This is done in the function EstimateDOA1.m, shown here, which has the
input argument sigma.
Run codegen at the command line to generate the mex function, EstimateDOA1_mex,
using the -args option to specify the type of input argument. Then run the mex function
with several different input parameters:
13-13
13 Code Generation
10.1882 44.3327
EstimateDOA1_mex(15)
az =
8.1620 46.2440
Increasing the value of sigma degrades the estimates of the azimuth angles.
13-14
Generate MEX Function Containing Persistent System Objects
function plot_ULA_response
azangles = [-90:90];
elangles = zeros(size(azangles));
fc = 100e9;
c = physconst('LightSpeed');
N = size(azangles,2);
lambda = c/fc;
d = 0.4*lambda;
numelements = 11;
resp = zeros(1,N);
sIso = phased.IsotropicAntennaElement(...
'FrequencyRange',[1,200]*1e9,...
'BackBaffled',false);
sULA = phased.ULA('Element',sIso,...
'NumElements',numelements,...
'ElementSpacing',d,...
'Taper',taylorwin(numelements).');
for n = 1:N
x = get_ULA_response(sULA,fc,azangles(n),elangles(n));
resp(n) = abs(x);
end
plot(azangles,20*log10(resp));
title('ULA Response');
xlabel('Angle (deg)');
ylabel('Response (db)');
grid;
end
13-15
13 Code Generation
'WeightsInputPort',false,...
'EnablePolarization',false);
end
resp = step(sAR,fc,[az;el]);
end
To create the code, run codegento create the mex-file plot_ULA_response_mex, and
execute the mex-file at the command line:
codegen plot_ULA_response
plot_ULA_response_mex;
which yields the plot
13-16
Generate MEX Function Containing Persistent System Objects
13-17
13 Code Generation
13-18
Functions and System Objects Supported for C/C++ Code Generation
13-19
13 Code Generation
13-20
Functions and System Objects Supported for C/C++ Code Generation
13-21
13 Code Generation
13-22
Functions and System Objects Supported for C/C++ Code Generation
13-23
13 Code Generation
13-24
Functions and System Objects Supported for C/C++ Code Generation
13-25
13-26
14
The class definition file contains the minimum elements required to define a System
object.
1 Create a MATLAB file named AddOne.m to contain the definition of your System
object.
edit AddOne.m
2 Subclass your object from matlab.System. Insert this line as the first line of your
file.
classdef AddOne < matlab.System
3 Add the stepImpl method, which contains the algorithm that runs when users call
the step method on your object. You always set the stepImpl method access to
protected because it is an internal method that users do not directly call or run.
All methods, except static methods, expect the System object handle as the first
input argument. You can use any name for your System object handle.
In this example, instead of passing in the object handle, ~ is used to indicate that
the object handle is not used in the function. Using ~ instead of an object handle
prevents warnings about unused variables from occurring.
By default, the number of inputs and outputs are both one. To change the number
of inputs or outputs, use the getNumInputsImpl or getNumOutputsImpl method,
respectively.
methods (Access = protected)
function y = stepImpl(~,x)
y = x + 1;
end
end
Note: Instead of manually creating your class definition file, you can use an option on
the New > System Object menu to open a template. The Basic template opens a simple
14-2
Define Basic System Objects
System object template. The Advanced template includes more advanced features of
System objects, such as backup and restore. The Simulink Extension template includes
additional customizations of the System object for use in the Simulink MATLAB System
block. You then can edit the template file, using it as guideline, to create your own
System object.
function y = stepImpl(~,x)
y = x + 1;
end
end
end
See Also
matlab.System | getNumInputsImpl | getNumOutputsImpl | stepImpl
Related Examples
• “Change Number of Step Inputs or Outputs” on page 14-4
More About
• “System Design and Simulation in MATLAB”
14-3
14 Define New System Objects
If you specify the inputs and outputs to the stepImpl method, you do not need to
specify the getNumInputsImpl and getNumOutputsImpl methods. If you have
a variable number of inputs or outputs (using varargin or varargout), include the
getNumInputsImpl or getNumOutputsImpl method, respectively, in your class
definition file.
14-4
Change Number of Step Inputs or Outputs
end
function validatePropertiesImpl(obj)
if ~((obj.numInputsOutputs == 2) ||...
(obj.numInputsOutputs == 3))
error('Only 2 or 3 input and outputs allowed.');
end
end
Use this syntax to run the algorithm with two inputs and two outputs.
x1 = 3;
x2 = 7;
[y1,y2] = step(AddOne,x1,x2);
To change the number of inputs or outputs, you must release the object before rerunning
it.
release(AddOne)
x1 = 3;
x2 = 7;
x3 = 10
[y1,y2,y3] = step(AddOne,x1,x2,x3);
14-5
14 Define New System Objects
function validatePropertiesImpl(obj)
if ~((obj.numInputsOutputs == 2) ||
(obj.numInputsOutputs == 3))
error('Only 2 or 3 input and outputs allowed.');
end
end
14-6
Change Number of Step Inputs or Outputs
end
See Also
getNumInputsImpl | getNumOutputsImpl
Related Examples
• “Validate Property and Input Values” on page 14-8
• “Define Basic System Objects” on page 14-2
More About
• “System Object Input Arguments and ~ in Code Examples” on page 14-48
14-7
14 Define New System Objects
Validate Properties
This example shows how to validate the value of a single property using
set.PropertyName syntax. In this case, the PropertyName is Increment.
methods
% Validate the properties of the object
function set.Increment(obj,val)
if val >= 10
error('The increment value must be less than 10');
end
obj.Increment = val;
end
end
This example shows how to validate the value of two interdependent properties using the
validatePropertiesImpl method. In this case, the UseIncrement property value
must be true and the WrapValue property value must be less than the Increment
property value.
Validate Inputs
This example shows how to validate that the first input is a numeric value.
14-8
Validate Property and Input Values
end
properties (PositiveInteger)
Increment = 1
WrapValue = 10
end
methods
% Validate the properties of the object
function set.Increment(obj, val)
if val >= 10
error('The increment value must be less than 10');
end
obj.Increment = val;
end
end
14-9
14 Define New System Objects
else
out = in + 1;
end
end
end
end
Note: All inputs default to variable-size inputs. See “Change Input Complexity or
Dimensions” for more information.
See Also
validateInputsImpl | validatePropertiesImpl
Related Examples
• “Define Basic System Objects” on page 14-2
More About
• “Methods Timing” on page 14-45
• “Property Set Methods”
• “System Object Input Arguments and ~ in Code Examples” on page 14-48
14-10
Initialize Properties and Setup One-Time Calculations
In this example, you allocate file resources by opening the file so the System object can
write to that file. You do these initialization tasks one time during setup, rather than
every time you call the step method.
In this example, you define the public Filename property and specify the value of that
property as the nontunable string, default.bin. Users cannot change nontunable
properties after the setup method has been called. Refer to the Methods Timing section
for more information.
properties (Nontunable)
Filename = 'default.bin'
end
Users cannot access private properties directly, but only through methods of the System
object. In this example, you define the pFileID property as a private property. You also
define this property as hidden to indicate it is an internal property that never displays to
the user.
Define Setup
You use the setupImpl method to perform setup and initialization tasks. You should
include code in the setupImpl method that you want to execute one time only. The
setupImpl method is called once during the first call to the step method. In this
example, you allocate file resources by opening the file for writing binary data.
methods
function setupImpl(obj)
obj.pFileID = fopen(obj.Filename,'wb');
if obj.pFileID < 0
error('Opening the file failed');
14-11
14 Define New System Objects
end
end
end
Although not part of setup, you should close files when your code is done using them. You
use the releaseImpl method to release resources.
14-12
Initialize Properties and Setup One-Time Calculations
end
See Also
releaseImpl | setupImpl | stepImpl
Related Examples
• “Release System Object Resources” on page 14-29
• “Define Property Attributes” on page 14-18
More About
• “Methods Timing” on page 14-45
14-13
14 Define New System Objects
Define the System object constructor, which is a method that has the same name as
the class (MyFile in this example). Within that method, you use the setProperties
method to make all public properties available for input when the user constructs the
object. nargin is a MATLAB function that determines the number of input arguments.
varargin indicates all of the object’s public properties.
methods
function obj = MyFile(varargin)
setProperties(obj,nargin,varargin{:});
end
end
methods
% You call setProperties in the constructor to let
% a user specify public properties of object as
% name-value pairs.
function obj = MyFile(varargin)
setProperties(obj,nargin,varargin{:});
end
14-14
Set Property Values at Construction Time
end
See Also
nargin | setProperties
Related Examples
• “Define Property Attributes” on page 14-18
• “Release System Object Resources” on page 14-29
14-15
14 Define New System Objects
pCount is an internal counter property of the System object obj. The user calls the
reset method, which calls the resetImpl method. In this example , pCount resets to 0.
Note: When resetting an object’s state, make sure you reset the size, complexity, and
data type correctly.
14-16
Reset Algorithm State
end
See Also
resetImpl
More About
• “Methods Timing” on page 14-45
14-17
14 Define New System Objects
Property attributes, which add details to a property, provide a layer of control to your
properties. In addition to the MATLAB property attributes, System objects can use these
three additional attributes—nontunable, logical, and positiveInteger. To specify
multiple attributes, separate them with commas.
Use the nontunable attribute for a property when the algorithm depends on the value
being constant once data processing starts. Defining a property as nontunable may
improve the efficiency of your algorithm by removing the need to check for or react to
values that change. For code generation, defining a property as nontunable allows the
memory associated with that property to be optimized. You should define all properties
that affect the number of input or output ports as nontunable.
System object users cannot change nontunable properties after the setup or step
method has been called. In this example, you define the InitialValue property, and set
its value to 0.
properties (Nontunable)
InitialValue = 0;
end
Logical properties have the value, true or false. System object users can enter 1 or
0 or any value that can be converted to a logical. The value, however, displays as true
or false. You can use sparse logical values, but they must be scalar values. In this
example, the Increment property indicates whether to increase the counter. By default,
Increment is tunable property. The following restrictions apply to a property with the
Logical attribute,
properties (Logical)
Increment = true
end
14-18
Define Property Attributes
In this example, the private property pCount is constrained to accept only real, positive
integers. You cannot use sparse values. The following restriction applies to a property
with the PositiveInteger attribute,
If your algorithm uses properties that hold state, you can assign those properties the
DiscreteState attribute . Properties with this attribute display their state values
when users call getDiscreteStateImpl via the getDiscreteState method. The
following restrictions apply to a property with the DiscreteState attribute,
14-19
14 Define New System Objects
properties (Logical)
% Whether to increment the counter
Increment = true
end
properties (DiscreteState)
% Count state variable
Count
end
function c = stepImpl(obj)
if obj.Increment && (obj.Count < obj.MaxValue)
obj.Count = obj.Count + 1;
else
disp(['Max count, ' num2str(obj.MaxValue) ',reached'])
end
c = obj.Count;
end
14-20
Define Property Attributes
end
More About
• “Class Attributes”
• “Property Attributes”
• “What You Cannot Change While Your System Is Running”
• “Methods Timing” on page 14-45
14-21
14 Define New System Objects
14-22
Hide Inactive Properties
c = obj.pCount;
end
See Also
isInactivePropertyImpl
14-23
14 Define New System Objects
String sets use two related properties. You first specify the user-visible property name
and default string value. Then, you specify the associated hidden property by appending
“Set” to the property name. You must use a capital “S” in “Set.”
In the “Set” property, you specify the valid string values as a cell array of the
matlab.system.Stringset class. This example uses Color and ColorSet as the
associated properties.
properties
Color = 'blue'
end
properties (Hidden,Transient)
ColorSet = matlab.system.StringSet({'red','blue','green'});
end
properties
Color = 'blue'
end
properties (Hidden,Transient)
% Let them choose a color
ColorSet = matlab.system.StringSet({'red','blue','green'});
end
14-24
Limit Property Values to Finite String Set
end
function releaseImpl(obj)
cla(Whiteboard.getWhiteboard());
hold on
end
end
methods (Static)
function a = getWhiteboard()
h = findobj('tag','whiteboard');
if isempty(h)
h = figure('tag','whiteboard');
hold on
end
a = gca;
end
end
end
14-25
14 Define New System Objects
type('Whiteboard.m');
See Also
matlab.system.StringSet
14-26
Process Tuned Properties
properties
MiddleC = 440
NumNotes = 12
end
14-27
14 Define New System Objects
function hz = stepImpl(obj,noteShift)
% A noteShift value of 1 corresponds to obj.MiddleC
hz = obj.pLookupTable(noteShift);
end
function processTunedPropertiesImpl(obj)
% Generate a lookup table of note frequencies
obj.pLookupTable = obj.MiddleC * ...
(1+log(1:obj.NumNotes)/log(12));
end
end
end
See Also
processTunedPropertiesImpl
14-28
Release System Object Resources
This method allows you to clear the axes on the Whiteboard figure window while keeping
the figure open.
methods
function releaseImpl(obj)
cla(Whiteboard.getWhiteboard());
hold on
end
end
properties (Hidden)
% Let user choose a color
ColorSet = matlab.system.StringSet({'red','blue','green'});
end
function releaseImpl(obj)
cla(Whiteboard.getWhiteboard());
hold on
14-29
14 Define New System Objects
end
methods (Static)
function a = getWhiteboard()
h = findobj('tag','whiteboard');
if isempty(h)
h = figure('tag','whiteboard');
hold on
end
a = gca;
end
end
end
See Also
releaseImpl
Related Examples
• “Initialize Properties and Setup One-Time Calculations” on page 14-11
14-30
Define Composite System Objects
This example defines a filter System object from an FIR System object and an IIR System
object.
To define a System object from other System objects, store those objects in your class
definition file as properties. In this example, FIR and IIR are separate System objects
defined in their own class-definition files. You use those two objects to calculate the pFir
and pIir property values.
properties (Nontunable, Access = private)
pFir % Store the FIR filter
pIir % Store the IIR filter
end
methods
function obj = Filter(varargin)
setProperties(obj,nargin,varargin{:});
obj.pFir = FIR(obj.zero);
obj.pIir = IIR(obj.pole);
end
end
properties (Nontunable)
zero = 0.01
pole = 0.5
end
14-31
14 Define New System Objects
end
methods
function obj = Filter(varargin)
setProperties(obj,nargin,varargin{:});
% Create instances of FIR and IIR as
% private properties
obj.pZero = Zero(obj.zero);
obj.pPole = Pole(obj.pole);
end
end
function resetImpl(obj)
reset(obj.pZero);
reset(obj.pPole);
end
function y = stepImpl(obj,x)
y = step(obj.pZero,x) + step(obj.pPole,x);
end
function releaseImpl(obj)
release(obj.pZero);
release(obj.pPole);
end
end
end
properties
Den = 1
end
14-32
Define Composite System Objects
methods
function obj = Pole(varargin)
setProperties(obj,nargin,varargin{:},'Den');
end
end
end
properties
Num = 1
end
methods
function obj = Zero(varargin)
setProperties(obj,nargin,varargin{:},'Num');
end
end
end
See Also
nargin
14-33
14 Define New System Objects
function y = stepImpl(obj)
if ~obj.isDone()
obj.NumSteps = obj.NumSteps + 1;
y = obj.NumSteps;
else
y = 0;
end
end
14-34
Define Finite Source Objects
bDone = obj.NumSteps==2;
end
end
end
See Also
matlab.system.mixin.FiniteSource
More About
• “What Are Mixin Classes?” on page 14-49
• “Subclassing Multiple Classes”
• “System Object Input Arguments and ~ in Code Examples” on page 14-48
14-35
14 Define New System Objects
Define a saveObjectImpl method to specify that more than just public properties
should be saved when the user saves a System object. Within this method, use the
default saveObjectImpl@matlab.System to save public properties to the struct,
s. Use the saveObject method to save child objects. Save protected and dependent
properties, and finally, if the object is locked, save the object’s state.
methods (Access = protected)
function s = saveObjectImpl(obj)
s = saveObjectImpl@matlab.System(obj);
s.child = matlab.System.saveObject(obj.child);
s.protected = obj.protected;
s.pdependentprop = obj.pdependentprop;
if isLocked(obj)
s.state = obj.state;
end
end
end
properties (Dependent)
dependentprop
end
14-36
Save System Object
methods
function obj = MySaveLoader(varargin)
obj@matlab.System();
setProperties(obj,nargin,varargin{:});
end
end
% Serialization
methods (Access = protected)
function s = saveObjectImpl(obj)
% Call the base class method
s = saveObjectImpl@matlab.System(obj);
function loadObjectImpl(obj,s,wasLocked)
% Load child System objects
obj.child = matlab.System.loadObject(s.child);
14-37
14 Define New System Objects
obj.protected = s.protected;
obj.pdependentprop = s.pdependentprop;
See Also
loadObjectImpl | saveObjectImpl
Related Examples
• “Load System Object” on page 14-39
14-38
Load System Object
properties (Dependent)
14-39
14 Define New System Objects
dependentprop
end
methods
function obj = MySaveLoader(varargin)
obj@matlab.System();
setProperties(obj,nargin,varargin{:});
end
end
% Serialization
methods (Access = protected)
function s = saveObjectImpl(obj)
% Call the base class method
s = saveObjectImpl@matlab.System(obj);
function loadObjectImpl(obj,s,wasLocked)
% Load child System objects
obj.child = matlab.System.loadObject(s.child);
14-40
Load System Object
See Also
loadObjectImpl | saveObjectImpl
Related Examples
• “Save System Object” on page 14-36
14-41
14 Define New System Objects
You can define your own clone method, which is useful for copying objects without saving
their state. The default cloneImpl method copies both a System object™ and its current
state. If an object is locked, the default cloneImpl creates a cloned object that is also
locked. An example of when you may want to write your own clone method is for cloning
objects that handle resources. These objects cannot allocate resources twice and you
would not want to save their states. To write your clone method, use the saveObject
and loadObject methods to perform the clone within the cloneImpl method.
See Also
cloneImpl | loadObjectImpl | saveObjectImpl
14-42
Define System Object Information
You can define your own info method to display specific information for your
System object. The default infoImpl method returns an empty struct. This
infoImpl method returns detailed information when the info method is called using
info(x,'details') or only count information if it is called using info(x).
methods (Access = protected)
function s = infoImpl(obj,varargin)
if nargin>1 && strcmp('details',varargin(1))
s = struct('Name','Counter',...
'Properties', struct('CurrentCount', ...
obj.pCount,'Threshold',obj.Threshold));
else
s = struct('Count',obj.pCount);
end
end
end
properties
Threshold = 1
end
properties (DiscreteState)
Count
end
function resetImpl(obj)
obj.Count = 0;
end
14-43
14 Define New System Objects
function y = stepImpl(obj,u)
if (u > obj.Threshold)
obj.Count = obj.Count + 1;
end
y = obj.Count;
end
function s = infoImpl(obj,varargin)
if nargin>1 && strcmp('details',varargin(1))
s = struct('Name','Counter',...
'Properties', struct('CurrentCount', ...
obj.pCount,'Threshold',obj.Threshold));
else
s = struct('Count',obj.pCount);
end
end
end
See Also
infoImpl
14-44
Methods Timing
Methods Timing
In this section...
“Setup Method Call Sequence” on page 14-45
“Step Method Call Sequence” on page 14-45
“Reset Method Call Sequence” on page 14-46
“Release Method Call Sequence” on page 14-47
14-45
14 Define New System Objects
14-46
Methods Timing
See Also
releaseImpl | resetImpl | setupImpl | stepImpl
Related Examples
• “Release System Object Resources” on page 14-29
• “Reset Algorithm State” on page 14-16
• “Set Property Values at Construction Time” on page 14-14
• “Define Basic System Objects” on page 14-2
More About
• “What Are System Object Methods?”
• “The Step Method”
• “Common Methods”
14-47
14 Define New System Objects
14-48
What Are Mixin Classes?
The following mixin classes are available for use with System objects.
14-49
14 Define New System Objects
• Define all one-time calculations in the setupImpl method and cache the results in a
private property. Use the stepImpl method for repeated calculations.
• For parameters that do not change, define them in a locked object as Nontunable
properties.
• If the number of System object inputs does not change, do not implement the
getNumInputsImpl method. Also do not implement the getNumInputsImpl
method when you explicitly list the inputs in the stepImpl method instead of
using varargin. The same caveats apply to the outputs, getNumOutputsImpl and
varargout.
• Variables that do not need to retain their values between calls should have local scope
for that method.
• If properties are accessed more than once in the stepImpl method, or in the
updateImpl and outputImpl methods, cache those properties as local variables
inside the method. Iterative calculations using cached local variables run faster than
calculations that must access the properties of an object. When the calculations for
the method complete, you can save the local cached results back to the properties of
that System object. Copy frequently used tunable properties into private properties.
• For best practices for including System objects in code generation, see “System
Objects in MATLAB Code Generation”.
14-50