www.gusucode.com > signal 案例源码程序 matlab代码 > signal/MeanFrequencyOfChirpsExample.m
%% Mean Frequency of Chirps % Generate 1024 samples of a chirp sampled at 1024 kHz. The chirp has an % initial frequency of 50 kHz and reaches 100 kHz at the end of the % sampling. Add white Gaussian noise such that the signal-to-noise ratio is % 40 dB. Reset the random number generator for reproducible results. % Copyright 2015 The MathWorks, Inc. %% nSamp = 1024; Fs = 1024e3; SNR = 40; rng default t = (0:nSamp-1)'/Fs; x = chirp(t,50e3,nSamp/Fs,100e3); x = x+randn(size(x))*std(x)/db2mag(SNR); %% % Estimate the mean frequency of the chirp. Plot the power spectral density % (PSD) and annotate the mean frequency. meanfreq(x,Fs) %% % Generate another chirp. Specify an initial frequency of 200 kHz, a final % frequency of 300 kHz, and an amplitude that is twice that of the first % signal. Add white Gaussian noise. x2 = 2*chirp(t,200e3,nSamp/Fs,300e3); x2 = x2+randn(size(x2))*std(x2)/db2mag(SNR); %% % Concatenate the chirps to produce a two-channel signal. Estimate the mean % frequency of each channel. y = meanfreq([x x2],Fs) %% % Plot the PSDs of the two channels and annotate their mean frequencies. meanfreq([x x2],Fs); %% % Add the two channels to form a new signal. Plot the PSD and annotate the % mean frequency. meanfreq(x+x2,Fs)