This is an interesting question. Shared here is a summary of the specific changes in the code (below this summary).
Scenario Update Rate:
- Non-working Code: The radarScenario object is instantiated with a StopTime of 10 seconds and no explicit UpdateRate is set.
- Working Code: The radarScenario is instantiated with a StopTime of 0.01 seconds and an UpdateRate of 0, which inherits the update rate from the radar sensor. This setting ensures that the scenario updates at the correct rate, matching the PRF.
Operating Frequency:
- Non-working Code: The operating frequency (Fc) is not explicitly set for the transmit and receive antennas in the radar transceiver.
- Working Code: The operating frequency (Fc) is explicitly set for both the transmit and receive antennas using rdr.TransmitAntenna.OperatingFrequency = Fc; and rdr.ReceiveAntenna.OperatingFrequency = Fc;.
Beamforming and Matrix Dimensions:
- Non-working Code: The code attempts to process each frame individually without accumulating a history of frames.
- Working Code: The code maintains a buffer of the last N frames (N = 15) using the lastNFrames array. This buffer is used to perform "beamforming" by summing the channels and ensuring that the input to plotResponse is a 2D matrix with fast time as the first dimension and slow time as the second dimension.
- Non-working Code: Directly plots the response using plotResponse without manipulating the data dimensions.
- Working Code: Performs a simple beamforming operation by summing across channels and reshaping the data to ensure that the matrix passed to plotResponse is correctly dimensioned for range-Doppler processing.
Doppler Response Configuration:
- Non-working Code: The Doppler FFT length and PRF are set, but the configuration may not properly handle the data dimensions.
- Working Code: Ensures the Doppler response is configured correctly with explicit properties for PRFSource and PRF, which might help in synchronizing the processing with the waveform characteristics.
These changes primarily address synchronization issues, proper frequency configuration, and correct handling of the signal processing chain, which are critical for generating an accurate range-Doppler map in a pulsed radar system.
c = 3e8;
Fs = 10e6;
Fc = 10e9;
rpos = [0;0;0];
tpos = [2000;0;0];
rvel = [0;0;0];
tvel = [40;0;0];
dmax = 12e3;
prf = c/(2*dmax);
bw = 2e6;
NumElems = 64;
% Need to update the scenario update rate to match the PRF. Set the update
% rate to 0 to inherit the update rate from the radar sensor
scenario = radarScenario('StopTime',0.01,'IsEarthCentered',false,'UpdateRate',0);
array = phased.ULA(NumElems,freq2wavelen(Fc)/2);
myWav = phased.LinearFMWaveform('SampleRate',Fs,'PRF',prf,...
'SweepBandwidth',bw,'PulseWidth',0.1/prf);
tgtTraj = kinematicTrajectory('Position',tpos,'Velocity',tvel);
rdrTraj = kinematicTrajectory('Position',rpos,'Velocity',rvel);
target = platform(scenario, 'Trajectory',tgtTraj);
radar = platform(scenario, 'Trajectory',rdrTraj);
% Need to make sure the sensor is operating at our Fc --> let's set the FC
% in the transmit antenna and receive antenna
rdr = radarTransceiver;
rdr.Waveform = myWav;
rdr.TransmitAntenna.Sensor = array;
rdr.TransmitAntenna.OperatingFrequency = Fc;
rdr.ReceiveAntenna.Sensor = array;
rdr.Receiver.SampleRate = Fs;
rdr.ReceiveAntenna.OperatingFrequency = Fc;
radar.Sensors = rdr;
myResponse = phased.RangeDopplerResponse(...
'RangeMethod','Matched Filter', ...
'PropagationSpeed',c, 'DopplerOutput','Speed',...
'SampleRate', Fs,'OperatingFrequency',Fc,...
'DopplerFFTLengthSource','Property', ...
'DopplerFFTLength',1024, 'PRFSource','Property', 'PRF', prf);
tstep = 1/prf;
m = 0;
N = 15;
lastNFrames = zeros(800, 64, N);
while advance(scenario)
m = m+1;
iqsig = receive(scenario);
PH = iqsig{1};
for ii = N:-1:1
if ii == 1
lastNFrames(:, :, ii) = PH;
else
lastNFrames(:, :, ii) = lastNFrames(:, :, ii-1);
end
end
% We need to make sure the last dimension (2nd dimension) of the matrix
% we're passing into the plotResponse function is subsequent pulses; to
% this end, let's do some "beamforming" in the straight forward
% direction (just sum all the channels) and then let's get rid of the
% middle dimension using squeeze so it's a 2D matrix with the first
% dimension being fast time and second dimension being slow time
if m >= N
beamformedLastN = squeeze(sum(lastNFrames, 2));
plotResponse(myResponse,beamformedLastN,getMatchedFilter(myWav))
drawnow
end
end