% DispChirps.m Script % % -- display three different kinds of chirp signals % as non-stationary signal % % -- visual comparison between the Fourier Analysis % and Phase Analysis % % -------------------------------------------------- % Xiaobai Sun % Duke CS % For the class of Numerical Analysis and Methods % -------------------------------------------------- clear all close all figid = 0; padz = zeros( 10, 1); % EXAMPLE 1: Compute the spectrogram of a linear chirp. t = 0:0.001:2; % 2 secs @ 1kHz sample rate y = chirp(t,0,1,150); % Start @ DC, cross 150Hz at t=1sec yf = fft( y ) ; figid = figid + 1; figure( figid ) subplot(3,1,1) plot( y(1:5:end) ) xlabel( 't' ) ylabel( 's(t)' ) subplot(3,1,2) plot( abs(yf(1:5:end)) ) xlabel( 'f' ) ylabel( ' Amplitude |S(f)|' ) subplot(3,1,3) spectrogram(y,256,250,256,1E3); % Display the spectrogram title( 'spectrogram of a linear chirp' ) % EXAMPLE 2: Compute the spectrogram of a quadratic chirp. t=-2:0.001:2; % +/-2 secs @ 1kHz sample rate y=chirp(t,100,1,200,'q'); % Start @ 100Hz, cross 200Hz at t=1se yf = fft( y ) ; figid = figid + 1; figure( figid ) subplot(3,1,1) plot( y(1:10:end) ) xlabel( 't' ) ylabel( 's(t)' ) subplot(3,1,2) plot( abs(yf(1:5:end)) ) xlabel( 'f' ) ylabel( ' Amplitude |S(f)|' ) subplot(3,1,3) spectrogram(y,128,120,128,1E3); % Display the spectrogram title( 'Quadratic chirp' ) % EXAMPLE 3: Compute the spectrogram of a logarithmic chirp t= 0:0.001:10; % 10 seconds @ 1kHz sample rate fo=10;f1=400; % Start at 10Hz, go up to 400Hz y=chirp(t,fo,10,f1,'logarithmic'); yf = fft( y ) ; figid = figid + 1; figure( figid ) subplot(3,1,1) plot( y(1:10:end) ) xlabel( 't' ) ylabel( 's(t)' ) subplot(3,1,2) plot( abs(yf(1:5:end)) ) xlabel( 'f' ) ylabel( ' Amplitude |S(f)|' ) subplot(3,1,3) spectrogram(y,256,200,256,1000); % Display the spectrogram. title( 'Logrithm chirp' )