www.gusucode.com > phased 案例源码 matlab代码程序 > phased/LocalAndGlobalCoordinateSystemsExample.m

    %% Global and Local Coordinate Systems Radar Example
% This example shows how several different coordinate systems come into play
% when modeling a typical radar scenario. The scenario considered here is a
% bistatic radar system consisting of a transmitting radar array, a target,
% and a receiving radar array. The transmitting radar antenna emits radar
% signals that propagate to the target, reflected off the target, and then
% propagate to the receiving radar.
%%
% Choose a signal frequency of 1 GHz.
fc = 1e9;
c = physconst('LightSpeed');
lam = c/fc;

%% Create All Radar System Components
% First, set up the transmitting radar array. The transmitting array is a
% 5-by-5 uniform rectangular array (URA) composed of isotropic antenna
% elements. The array is stationary and is located at the position
% _(50,50,50)_ meters in the global coordinate system. Although you
% position arrays in the global system, array element positions are always
% defined in the array local coordinate system. The tranmitted signal
% strength in any direction is a function of the transmitting angle in the
% local array coordinate system. Specify the orientation of the array.
% Without any orientation, local array axes are aligned with the global
% coordinate system. Choose an array orientation so that the array normal
% vector points approximately in the direction of the target. Do this by
% rotating the array 90° around the _z_-axis. Then, rotate the array
% slightly by 2° around the _y_-axis and 1° around the _z_-axis again.
sAnt = phased.IsotropicAntennaElement('BackBaffled',false);
stxURA = phased.URA('Element',sAnt','Size',[5,5],'ElementSpacing',0.4*lam*[1,1]);
txradarAx = rotz(1)*roty(2)*rotz(90);
sTxRadar = phased.Platform('InitialPosition',[50;50;50],...
    'Velocity',[0;0;0],'InitialOrientationAxes',txradarAx,...
    'OrientationAxesOutputPort',true);
sRad = phased.Radiator('Sensor',stxURA,'PropagationSpeed',c,...
    'WeightsInputPort',true,'OperatingFrequency',fc);
sSV = phased.SteeringVector('SensorArray',stxURA,'PropagationSpeed',c,...
    'IncludeElementResponse',true);
%%
% Next, position a target approximately 5 km from the transmitter along the
% global coordinate system _y_-axis and moving in the _x_-direction.
% Typically, you specify radar cross-section values as functions of the
% incident and reflected ray angles with respect to the local target axes. Choose
% any target orientation with respect to the global coordinate
% system.
%%
% Simulate a non-fluctuating target, but allow the RCS to change at each
% call to the |step| method. Set up a simple inline function, |rcsval|, to
% compute ficticious but reasonable values for RCS at different ray angles.
tgtAx = rotz(10)*roty(15)*rotx(20);
sTarget = phased.Platform('InitialPosition',[100; 10000; 100],...
    'MotionModel','Acceleration','InitialVelocity',[-20;0;0],'Acceleration',[.015;.015;0],...
    'InitialOrientationAxes',tgtAx,'OrientationAxesOutputPort',true);
sTgt = phased.RadarTarget('MeanRCS',1,'OperatingFrequency',fc,...
    'Model','Nonfluctuating','MeanRCSSource','Input port');
rcsval = @(az1,el1,az2,el2) 2*abs(cosd((az1+az2)/2 - 90)*cosd((el1+el2)/2));
%%
% Finally, set up the receiving radar array. The receiving array is also a
% 5-by-5 URA composed of isotropic antenna elements. The array is
% stationary and is located 150 meters in the _z_-direction from the
% transmitting array. The received signal strength in any direction is a
% function of the incident angle of the signal in the local array
% coordinate system. Specify an orientation of the array. Choose an
% orientation so that this array also points approximately in the
% _y_-direction towards the target but not quite aligned with the first
% array. Do this by rotating the array 92° around the _z_-axis and then
% 5° around the _x_-axis.
rxradarAx = rotx(5)*rotz(92);
sRxRadar = phased.Platform('InitialPosition',[50;50;200],...
    'Velocity',[0;0;0],'InitialOrientationAxes',rxradarAx,...
    'OrientationAxesOutputPort',true);
srxURA = phased.URA('Element',sAnt','Size',[5,5],'ElementSpacing',0.4*lam*[1,1]);

%%
% In summary, four different coordinate systems are needed to describe
% the radar scenario. These are
%%
% # The global coordinate system.
% # A local radar coordinate system defined by the transmitting
% radar axes.
% # A local coordinate system defined by the target axes.
% # A second local radar coordinate system defined by the receiving
% radar axes.
%
% The figure here illustrates the four coordinate systems. It is not to scale and does not
% accurately represent the scenario in the example code.
%
% <<../CoordinateSystems.png>>
%
%% Specify Transmitted Waveform and Transmitter Amplification
% Use a linear FM waveform as the transmitted signal. Assume a sampling
% frequency of 1 MHz, a pulse repetition frequency of 5 kHz, and a pulse
% length of 100 microseconds. Set the transmitter peak output power
% to 1000 W and the gain to 40.0.
tau = 100e-6;
prf = 5000;
fs = 1e6;
sWav = phased.LinearFMWaveform('PulseWidth',tau,...
    'OutputFormat','Pulses','NumPulses',1,'PRF',prf,'SampleRate',fs);
sTransmit = phased.Transmitter('PeakPower',1000.0,'Gain',40);
%%
% Create a matched filter from the transmitted waveform.
sMF = phased.MatchedFilter('Coefficients',getMatchedFilter(sWav));

%% Specify Propagation Channels
% Use free-space models for the propagation of the signal from the
% transmitting radar to the target and back to the receiving radar.
sFS1 = phased.FreeSpace('OperatingFrequency',fc,...
    'TwoWayPropagation',false);
sFS2 = phased.FreeSpace('OperatingFrequency',fc,...
    'TwoWayPropagation',false);

%% Specify Phaseshift Beamformer
% Create a phase-shift beamformer. Point the mainlobe of the beamformer in
% a specific direction with respect to the local receiver coordinate
% system. This direction is chosen to be one through which the target passes
% at some time in its motion. This choice lets us demonstrate how the
% beamformer response changes as the target passes through the mainlobe.
rxangsteer = [22.2244;-5.0615];
srxBF = phased.PhaseShiftBeamformer('SensorArray',srxURA,...
    'DirectionSource','Property','Direction',rxangsteer,...
    'PropagationSpeed',c,'OperatingFrequency',fc);

%% Simulation loop
% Each iteration of the processing lool performs these operations:
%
% # Updates positions of the radars and target.
% # Generates the LFM waveform.
% # Amplifies the waveform.
% # Radiates the signal from the transmitting antenna array.
% # Propagates the signal to the target.
% # Reflects the signal from the target.
% # Propagates the signal from the target to the receiving antenna array.
% # Collects the received signal at the receiving antenna.
% # Beamforms the arriving signal at the receiving antenna.
% # Match-filters the beamformed signal and find its peak value.
%
%%
% Transmit 100 pulses of the waveform. Transmit one pulse every 100
% milliseconds.
rng default
t = 0;
Npulse = 100;
dt = 0.1;
%%
% Create storage for later plotting.
azes1 = zeros(Npulse,1);
elevs1 = zeros(Npulse,1);
azes2 = zeros(Npulse,1);
elevs2 = zeros(Npulse,1);
rxsig = zeros(Npulse,1);
%%
% Enter the simulation loop.
for k = 1:Npulse
    t = t + dt;
    %%
    % Generate the transmitted waveform.
    waveform = step(sWav);
    %%
    % First, update the positions of the radars and targets. All positions
    % and velocities are defined with respect to the global coordinate
    % system. Because the |OrientationAxesOutputPort| property of the
    % target System object(TM) is set to |true|, you can obtain the
    % instantaneous local target axes, |tgtAx1|, from the |step| method.
    % These axes are needed to compute the target RCS. The array local
    % axes are fixed so you do not need to update them.
    [txradarPos,txradarVel] = step(sTxRadar,t);
    [rxradarPos,rxradarVel] = step(sRxRadar,t);
    [tgtPos,tgtVel,tgtAx1] = step(sTarget,t);
    
    %%
    % Compute the instantaneous range and direction of the target from the
    % transmitting radar. The strength of the transmitted wave depends
    % upon the array gain pattern. This pattern is a function of direction
    % angles with respect to the local radar axes. You can compute the
    % direction of the target with respect to the transmitter local axes
    % using the |rangeangle| function with an optional argument that
    % specifies the local radar axes, |txradarAx|. (Without this additional
    % argument, |rangeangle| returns the azimuth and elevation angles with
    % respect to the global coordinate system).
     [~,tgtang_tlcs] = rangeangle(tgtPos,txradarPos,txradarAx);
    %%
    % An alternative way to compute the direction angles is to first
    % compute them in the global coordinate system and then convert them
    % using the |global2localcoord| function.
    %%
    % Create the transmitted waveform. The transmitted waveform is an
    % amplified version of the generated waveform.
    txwaveform = step(sTransmit,waveform);
    %%
    % Radiate the signal in the instantaneous target direction. Recall that
    % the radiator is not steered in this direction but in an angle defined by the steering
    % vector, |txangsteer|. The steering angle is chosen because the target
    % passes through this direction during its motion. A plot will
    % let us see the improvement in the response as the target moves into
    % the main lobe of the radar.
    txangsteer = [23.1203;-0.5357];
    sv1 = step(sSV,fc,txangsteer);
    wavrad = step(sRad,txwaveform,tgtang_tlcs,conj(sv1));
    %%
    % Propagate the signal from the transmitting radar to the target.
    % Propagation coordinates are in the global coordinate system.
    wavprop1 = step(sFS1,wavrad,txradarPos,tgtPos,txradarVel,tgtVel);
    %%
    % Reflect the waveform from target back to the receiving radar array.
    % Use the simple angle-dependent RCS model defined previously. Inputs
    % to the rcs-model are azimuth and elevation of the incoming and
    % reflected rays with respect to the local target coordinate system.
    [~,txang_tgtlcs] = rangeangle(txradarPos,tgtPos,tgtAx1);
    [~,rxang_tgtlcs] = rangeangle(rxradarPos,tgtPos,tgtAx1);
    rcs = rcsval(txang_tgtlcs(1),txang_tgtlcs(2),rxang_tgtlcs(1),rxang_tgtlcs(2));
    wavreflect = step(sTgt,wavprop1,rcs);
    ns = size(wavreflect,1);
    tm = [0:ns-1]/fs*1e6;
    %%
    % Propagate the signal from the target to the receiving radar.
    % As before, all coordinates for signal propagation are expressed in the global
    % coordinate system.
    wavprop2 = step(sFS2,wavreflect,tgtPos,rxradarPos,tgtVel,rxradarVel);
    %%
    % Compute the response of the receiving antenna array in the direction
    % from which the radiation is coming. First, use the |rangeangle|
    % function to compute the direction of the target with respect to the
    % receiving array local axes, by specifying the receiver local
    % coordinate system, |rxradarAx|.
    [tgtrange_rlcs,tgtang_rlcs] = rangeangle(tgtPos,rxradarPos,rxradarAx);
    %%
    % Store the ranges and direction angles for later plotting.
    azes1(k) = tgtang_tlcs(1);
    elevs1(k) = tgtang_tlcs(2);
    azes2(k) = tgtang_rlcs(1);
    elevs2(k) = tgtang_rlcs(2);
    %%
    % Simulate an incoming plane wave at each element from the current
    % direction of the target calculated in the receiver local coordinate
    % system.
    wavcoll = collectPlaneWave(srxURA,wavprop2,tgtang_rlcs,fc);
    %%
    % Beamform the arriving wave. In this scenario, the receiver beamformer
    % points in the direction, |rxangsteer|, specified by the |Direction|
    % property of the |phased.PhaseShiftBeamformer| System object. When the
    % target actually lies in that direction, the response of the array
    % maximized.
    wavbf = step(srxBF,wavcoll);
    %%
    % Perform match filtering of the beamformed received wave and then find and
    % store the maximum value of each pulse for display. This value will be
    % plotted after the simulation loop ends.
    y = step(sMF,wavbf);
    rxsig(k) = max(abs(y));
end

%%
% Plot the target track in azimuth and elevation with respect to the
% transmitter local coordinates. The red circle denotes the direction
% toward which the transmitter array points.
figure
plot(azes1,elevs1,'.b')
grid
xlabel('Azimuth (degrees)')
ylabel('Elevation (degrees)')
title('Target Track in Transmitter Local Coordinates')
hold on
plot(txangsteer(1),txangsteer(2),'or')
hold off

%%
% Plot the target track in azimuth and elevation with respect to the
% receiver local coordinates. The red circle denotes the direction toward
% which the beamformer points.
figure
plot(azes2,elevs2,'.b')
grid
xlabel('Azimuth (degrees)')
ylabel('Elevation (degrees)')
title('Target Track in Receiver Local Coordinates')
hold on
plot(rxangsteer(1),rxangsteer(2),'or')
hold off

%%
% Plot the returned signal amplitude vs azimuth in the receiver local
% coordinates. The value of the amplitude depends on several factors.
figure;
plot(azes2,rxsig,'.')
grid
xlabel('Azimuth (degrees)')
ylabel('Amplitude')
title('Amplitude vs Azimuth in Receiver Local Coordinates')