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

    %% Create Rectangular Pulses with Variable PRF
% Construct rectangular waveforms with two pulses each.
% Set the sample rate to 1 MHz, a pulse width of 50 microseconds, and a duty
% cycle of 20%. Vary the pulse repetition frequency.
%%
% Set the sample rate and PRF. The ratio of sample rate to PRF must be an integer.
fs = 1e6;
PRF = [10000,25000];
sRFM = phased.RectangularWaveform('OutputFormat','Pulses','SampleRate',fs,...
    'DurationSpecification','Duty Cycle','DutyCycle',.2,...
    'PRF',PRF,'NumPulses',2,'PRFSelectionInputPort',true);
%%
% Obtain and plot the rectangular waveforms. For the first call to the
% |step| method, set the PRF to 10kHz using the PRF index. For the next call, set the PRF
% to 25 kHz. For the final call, set the PRF to 10kHz.
wav = [];
wav1 = step(sRFM,1);
wav = [wav; wav1];
wav1 = step(sRFM,2);
wav = [wav; wav1];
wav1 = step(sRFM,1);
wav = [wav; wav1];
nsamps = size(wav,1);
t = [0:(nsamps-1)]/sRFM.SampleRate;
plot(t*1e6,real(wav))
xlabel('Time (\mu sec)')
ylabel('Amplitude')
grid