www.gusucode.com > signal 案例源码程序 matlab代码 > signal/PowerSpectralDensitiesOfChirpsExample.m
%% Power Spectral Densities of Chirps % Compute and display the PSD of each segment of a quadratic chirp that % starts at 100 Hz and crosses 200 Hz at _t_ = 1 s. Specify a sample rate % of 1 kHz, a segment length of 128 samples, and an overlap of 120 samples. % Use 128 DFT points and the default Hamming window. % Copyright 2015 The MathWorks, Inc. %% t = 0:0.001:2; x = chirp(t,100,1,200,'quadratic'); spectrogram(x,128,120,128,1e3,'yaxis') title('Quadratic Chirp') %% % Compute and display the PSD of each segment of a linear chirp that starts % at DC and crosses 150 Hz at _t_ = 1 s. Specify a sample rate of 1 kHz, a % segment length of 256 samples, and an overlap of 250 samples. Use the % default Hamming window and 256 DFT points. t = 0:0.001:2; x = chirp(t,0,1,150); spectrogram(x,256,250,256,1e3,'yaxis') title('Linear Chirp') %% % Compute and display the PSD of each segment of a logarithmic chirp % sampled at 1 kHz that starts at 20 Hz and crosses 60 Hz at _t_ = 1 s. % Specify a segment length of 256 samples and an overlap of 250 samples. % Use the default Hamming window and 256 DFT points. t = 0:0.001:2; x = chirp(t,20,1,60,'logarithmic'); spectrogram(x,256,250,[],1e3,'yaxis') title('Logarithmic Chirp') %% % Use a logarithmic scale for the frequency axis. The spectrogram becomes a % line. ax = gca; ax.YScale = 'log';