DSP Blockset
  Go to block:
    Search    Help Desk 

Running Operations

A running operation is one that processes successive sample-based or frame-based inputs, and computes a result that reflects both present and past inputs. A reset port enables you to restart this tracking at any time. The running statistic is computed for each input channel independently, so the block's output has the same number of channels as the input.

Sample-based inputs:

Frame-based inputs:

For example, in running mode (Running selected from the Mode parameter) the Maximum block outputs a frame-by-frame record of the input's maximum value over time.

The figure below illustrates how a Maximum block in running mode operates on a sample vector sequence.

Demonstration Model: Running Operation

The DSP Blockset includes a demo that illustrates the running mode of a few statistics blocks.

To try the demo model:

   1.
Double-click on the Demos block in the top-level DSP Blockset library,

or type demos at the MATLAB command line.
   2.
Find the demo called Statistical Functions and open it.
The model, shown below, feeds a noisy sine wave into the Maximum, Mean, and Variance blocks. A Discrete Pulse Generator resets the blocks every 100 seconds, and a Scope displays the block outputs.

   3.
Start the simulation by selecting Start from the Simulation menu.
The Scope displays the output of each function block. Stop the simulation at any time by selecting Stop from the Simulation menu.

Example: Sliding Windows

You can use the basic statistics operations in conjunction with the Buffer block to implement basic sliding window statistics operations. A sliding window is like a stencil that you move along a data stream, exposing only a set number of data points at one time. For example, you may want to process data in 10-point frames, moving the window along by one sample point for each operation.

One way to implement a sliding window is shown below:

The Buffer block's Buffer size (Mo) parameter determines the size of the window. The Buffer overlap (L) parameter defines the "slide factor" for the window. At each sample instant, the window slides by Mo-L points. The Buffer overlap is often Mo-1 (the same as the Shift Register block), so that a new statistic is computed for every new signal sample.

Construct the model using:

To try the model:

   1.
Create test data. At the MATLAB prompt, enter:
   2.
Set the Signal From Workspace block parameters:
  1. Signal = A
  2. Sample time = 0.1
   3.
Set the Buffer block parameters:
  1. Buffer size = 128
  2. Buffer overlap = 127
   4.
Set the Maximum number of inputs to record in the Signal To Workspace block to 1000.
   5.
Set the simulation parameters:
  1. Select Parameters from the Simulation menu.
  2. Start time = 0.0
  3. Stop time = 25.6, the length of A multiplied by the sample period.
   6.
Start the simulation by selecting Start from the Simulation menu.
The simulation stops automatically when it reaches the specified Stop Time. Look at the contents of the yout variable. yout(129) contains the mean for the first 128 points of the test vector A. Note that yout(1) is 0, which was the initial output of the Buffer block.



[ Previous | Help Desk | Next ]