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

    %% Pulses of Rectangular Waveform
% This example shows how to create rectangular pulse waveform signals
% having different durations. The example plots two pulses of each
% waveform.
%%
% *Note:* This example runs only in R2016b or later. If you are using an earlier
% release, replace each call to the function with the equivalent |step|
% syntax. For example, replace |myObject(x)| with |step(myObject,x)|.
%%
% 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.
waveform = 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.
waveform2 = clone(waveform);
waveform.PulseWidth = 10e-6;

%%
% |sRect| and |sRect1| now specify different rectangular pulses because you
% changed the pulse width of |waveform|.

%%
% Execute the System objects to return two pulses of your rectangular pulse
% waveforms.
y = waveform();
y2 = waveform2();

%%
% Plot the real part of the waveforms.
totaldur = 2*1/waveform.PRF;
totnumsamp = totaldur*waveform.SampleRate;
t = unigrid(0,1/waveform.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(y2))
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)