User`s guide
4 DSP Operations
4-22
selected, for example) the Maximum block finds the maximum value in each
column of the current input, and returns this result at the top output (
Val).
Each consecutive
Val output therefore has the same number of columns as the
input, but only one row. Furthermore, the values in a given output only depend
on the values in the corresponding input. The block repeats this operation for
each successive input.
This type of operation is exactly equivalent to the MATLAB command
val = max(u) % Equivalent MATLAB code
which computes the maximum of each column in input u.
The next section provides an example of a basic statistical operation.
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 128-sample frames, moving the
window along by one sample point for each operation. One way to implement
such a sliding window is shown in the model below.
The Buffer block’s
Buffer size (M
o
) 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 M
o
-L points. The Buffer
overlap
is often M
o
-1 (the same as the Delay Line block), so that a new statistic
is computed for every new signal sample.
To build the model, make the following settings:
•In the Signal From Workspace block, set:
-
Signal = 1:256
- Sample time = 0.1
- Samples per frame = 1