www.gusucode.com > signal 案例源码程序 matlab代码 > signal/AnalyticEnvelopesOfDecayingSinusoidUsingFilterExample.m
%% Analytic Envelopes of Multichannel Signal Using Filter % Create a two-channel signal sampled at 1 kHz for 3 seconds: % % * One channel is an exponentially decaying sinusoid. Specify a frequency % of 7 Hz and a time constant of 2 seconds. % % * The other channel is a time-displaced Gaussian-modulated chirp with a % DC value of 2. Specify an initial chirp frequency of 30 Hz that decays to % 5 Hz after 2 seconds. % % Plot the signal. % Copyright 2015 The MathWorks, Inc. t = 0:1/1000:3; q1 = sin(2*pi*7*t).*exp(-t/2); q2 = chirp(t,30,2,5).*exp(-(2*t-3).^2)+2; q = [q1;q2]'; plot(t,q) %% % Compute the upper and lower envelopes of the signal. Use a Hilbert filter % with a length of 100. Plot the channels and the envelopes. Use solid lines for % the upper envelopes and dashed lines for the lower envelopes. [up,lo] = envelope(q,100,'analytic'); hold on plot(t,up,'-',t,lo,'--') hold off %% % Call |envelope| without output arguments to produce a plot of the signal % and its envelopes as a function of sample number. Increase the filter length % to 300 to obtain a smoother shape. The |'analytic'| flag is the default when % you specify two input arguments. envelope(q,300) %% % % %