www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/ComputeTheMovingMinimumOfASineWaveSignalExample.m

    %% Moving Minimum of Sine Wave Signal
% Compute the moving minimum of a sum of three sine waves with varying 
% amplitude. Use a sliding window of length 30.

%% Initialization
% Set up an input signal that is a sum of three sine waves with frequences 
% at 2 Hz, 5 Hz, and 10 Hz. The sampling frequency is 100 Hz. Create a
% |dsp.MovingMinimum| object with a window length of 30. Create a time 
% scope for viewing the output.
sin = dsp.SineWave('SampleRate',100,...
    'Frequency',[2 5 10],...
    'SamplesPerFrame',100);
movMin = dsp.MovingMinimum(30);
scope  = dsp.TimeScope('SampleRate',100,...
    'TimeSpanOverrunAction','Scroll',...
    'TimeSpan',10,'ShowGrid',true,...
    'YLimits',[-4.5 4.5]);

%% Compute the Moving Minimum
% Each sine wave component of the input signal has a different amplitude
% that varies with the iteration. Use the |movMin| object to determine the
% minimum value of the current sample and the past 29 samples of the input
% signal.
for index = 1:100
    sin.Amplitude = rand(1,3);
    x = sum(sin(),2);
    xmin = movMin(x);
    scope([x,xmin])
end