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

    %% Plot Stepped-FM Waveform and Spectrum
% Create a stepped frequency pulse waveform object. Assume the default
% value, 1 MHz, for the sample rate. Then, plot the waveform.

%%
% Create the SteppedFMWaveform System object(TM) with 20 kHz frequency step
% size.
sSFM = phased.SteppedFMWaveform('NumSteps',3,'FrequencyStep',20e3);
fs = sSFM.SampleRate;
%%
% Plot the third pulse of the wave using the |phased.SteppedFMWaveform.plot| method. Pass in
% the pulse number using the |'PulseIdx'| name-value pair.
plot(sSFM,'PulseIdx',3);

%%
% Alternatively, call the |step| method three times to
% obtain three pulses. Collect the
% three pulses in a single time series. Then plot the waveform using the |plot|
% function. You can see the full duty cycles of the pulses.
wavfull = [];
wav = step(sSFM);
wavfull = [wavfull;wav];
wav = step(sSFM);
wavfull = [wavfull;wav];
wav = step(sSFM);
wavfull = [wavfull;wav];
nsamps = size(wavfull,1);
t = [0:(nsamps-1)]/fs*1e6;
plot(t,real(wavfull))
xlabel('Time (\mu sec)')
ylabel('Amplitude')
grid

%%
% Plot the spectrum using the |spectrogram| function. Assume an fft of 64
% samples and a 50% overlap. Window the signal with a hamming function.
nfft1 = 64;
nov = floor(0.5*nfft1);
spectrogram(wavfull,hamming(nfft1),nov,nfft1,fs,'centered','yaxis')