MATLAB: Problem Matched Filtering in Matlab.

errormatched filteringMATLABPhased Array System Toolboxproblem

I got the source code for simulation Mached Filtering in Matlab :
clear; clc
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);
htx.PeakPower = Pt;
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);
hmf = phased.MatchedFilter(...
'Coefficients',getMatchedFilter(hwav),...
'GainOutputPort',true);
% 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 = step(hrec,wf,~txstatus);
[mf_puls,mfgain] = step(hmf,rx_puls);
% Get group delay of matched filter
Gd = length(hmf.Coefficients)-1;
% The group delay is constant
% Shift the matched filter output
mf_puls=[mf_puls(Gd+1:end); mf_puls(1:Gd)];
subplot(2,1,1);
t = unigrid(0,1e-6,1e-4,'[)');
rangegates = c.*t;
rangegates = rangegates/2;
plot(rangegates,abs(rx_puls)); title('Received Pulse');
ylabel('Amplitude'); hold on;
plot([tgtrng, tgtrng], [0 max(abs(rx_puls))],'r');
subplot(2,1,2)
plot(rangegates,abs(mf_puls)); title('With Matched Filtering');
xlabel('Meters'); ylabel('Amplitude'); hold on;
plot([tgtrng, tgtrng], [0 max(abs(mf_puls))],'r');

Best Answer

This is because you are using an older version of Phased Array System Toolbox. Technically, you just need to replace the following lines
wf = step(hspace,wf,txloc,tgtloc,[0;0;0],[0;0;0]);
with
wf = step(hspace,wf,txloc,tgtloc);
and it should run. However, you may want to find the corresponding example in your version to make sure other things are matched too.
The additional arguments are added in a later release so the Doppler effect within a pulse can be modeled. This is important for modeling range-Doppler coupling effect.
HTH