Find maximum values in input or sequence of inputs
Statistics
dspstat3
The Maximum block identifies the value and/or position of the
largest element in each row or column of the input, along vectors
of a specified dimension of the input, or of the entire input. The
Maximum block can also track the maximum values in a sequence of inputs
over a period of time. The Mode parameter specifies
the block's mode of operation and can be set to Value
, Index
, Value
and Index
, or Running
.
The Maximum block supports real and complex floatingpoint,
fixedpoint, and Boolean inputs. Real fixedpoint inputs can be either
signed or unsigned, while complex fixedpoint inputs must be signed.
The data type of the maximum values output by the block match the
data type of the input. The index values output by the block are double
when
the input is double
, and uint32
otherwise.
For the Value
, Index
,
and Value and Index
modes, the Maximum block produces
identical results as the MATLAB^{®} max
function
when it is called as [y I] = max(u,[],D)
, where u and y are
the input and output, respectively, D is the dimension,
and I is the index.
When the Mode parameter is set to Value
,
the block computes the maximum value in each row or column of the
input, along vectors of a specified dimension of the input, or of
the entire input at each sample time, and outputs the array y.
Each element in y is the maximum value in the corresponding
column, row, vector, or entire input. The output y depends
on the setting of the Find the maximum value over parameter.
For example, consider a 3dimensional input signal of size MbyNbyP:
Each row
— The output
at each sample time consists of an Mby1byP array,
where each element contains the maximum value of each vector over
the second dimension of the input. For an input that is an MbyN matrix,
the output at each sample time is an Mby1 column
vector.
Each column
— The
output at each sample time consists of a 1byNbyP array,
where each element contains the maximum value of each vector over
the first dimension of the input. For an input that is an MbyN matrix,
the output at each sample time is a 1byN row
vector.
In this mode, the block treats lengthM unoriented vector inputs as Mby1 column vectors.
Entire input
— The
output at each sample time is a scalar that contains the maximum value
in the MbyNbyP input
matrix.
Specified dimension
—
The output at each sample time depends on Dimension.
If Dimension is set to 1
,
the output is the same as that when you select Each column
.
If Dimension is set to 2
,
the output is the same as when you select Each row
.
If Dimension is set to 3
,
the output at each sample time is an MbyN matrix
containing the maximum value of each vector over the third dimension
of the input.
For complex inputs, the block selects the value in each row or column of the input, along vectors of a specified dimension of the input, or of the entire input that has the maximum magnitude squared as shown below. For complex value $$u=a+bi$$, the magnitude squared is $${a}^{2}+{b}^{2}$$.
When Mode is set to Index
,
the block computes the maximum value in each row or column of the
input, along vectors of a specified dimension of the input, or of
the entire input, and outputs the index array I.
Each element in I is an integer indexing the maximum
value in the corresponding column, row, vector, or entire input. The
output I depends on the setting of the Find
the maximum value over parameter. For example, consider
a 3dimensional input signal of size MbyNbyP:
Each row
— The output
at each sample time consists of an Mby1byP array,
where each element contains the index of the maximum value of each
vector over the second dimension of the input. For an input that is
an MbyN matrix, the output
at each sample time is an Mby1 column vector.
Each column
— The
output at each sample time consists of a 1byNbyP array,
where each element contains the index of the maximum value of each
vector over the first dimension of the input. For an input that is
an MbyN matrix, the output
at each sample time is a 1byN row vector.
In this mode, the block treats lengthM unoriented vector inputs as Mby1 column vectors.
Entire input
— The
output at each sample time is a 1by3 vector that contains the location
of the maximum value in the MbyNbyP input
matrix. For an input that is an MbyN matrix,
the output will be a 1by2 vector.
Specified dimension
—
The output at each sample time depends on Dimension.
If Dimension is set to 1, the output is the same
as when you select Each column
. If Dimension is
set to 2, the output is the same as when you select Each
row
. If Dimension is set to 3,
the output at each sample time is an MbyN matrix
containing the indices of the maximum values of each vector over the
third dimension of the input.
When a maximum value occurs more than once, the computed index
corresponds to the first occurrence. For example, when the input is
the column vector [3 2 1 2 3]'
, the computed onebased
index of the maximum value is 1
rather than 5
when Each
column
is selected.
When inputs to the block are doubleprecision values, the index values are doubleprecision values. Otherwise, the index values are 32bit unsigned integer values.
When Mode is set to Value
and Index
, the block outputs both the maxima and the
indices.
When Mode is set to Running
,
the block tracks the maximum value of each channel in a time sequence
of MbyN inputs. In this mode,
you must also specify a value for the Input processing parameter:
When you select Elements as channels
(sample based)
, the block outputs an MbyN array.
Each element y_{ij} of the
output contains the maximum value observed in element u_{ij} for
all inputs since the last reset.
When you select Columns as channels (frame
based)
, the block outputs an MbyN matrix.
Each element y_{ij} of the
output contains the maximum value observed in the jth
column of all inputs since the last reset, up to and including element u_{ij} of
the current input.
When your inputs are of variable size, and you set the Mode to Running
,
there are two options:
If you set the Input processing parameter
to Elements as channels (sample based)
,
the state is reset.
If you set the Input processing parameter
to Columns as channels (frame based)
, then
there are two cases:
When the input size difference is in the number of channels (i.e., number of columns), the state is reset.
When the input size difference is in the length of channels (i.e., number of rows), there is no reset and the running operation is carried out as usual.
The block resets the running maximum whenever a reset event is detected at the optional Rst port. The reset sample time must be a positive integer multiple of the input sample time.
When a reset event occurs while the Input processing parameter
is set to Elements as channels (sample based)
,
the running maximum for each channel is initialized to the value in
the corresponding channel of the current input. Similarly, when the Input
processing parameter is set to Columns as
channels (frame based)
, the running maximum for each
channel is initialized to the earliest value in each channel of the
current input.
You specify the reset event in the Reset port menu:
None
— Disables the Rst
port.
Rising edge
— Triggers
a reset operation when the Rst input does one of the following:
Rises from a negative value to a positive value or zero
Rises from zero to a positive value, where the rise is not a continuation of a rise from a negative value to zero (see the following figure)
Falling edge
— Triggers
a reset operation when the Rst
input does one of
the following:
Falls from a positive value to a negative value or zero
Falls from zero to a negative value, where the fall is not a continuation of a fall from a positive value to zero (see the following figure)
Either edge
— Triggers
a reset operation when the Rst
input is a Rising
edge
or Falling edge
(as
described above)
Nonzero sample
—
Triggers a reset operation at each sample time that the Rst
input
is not zero
Note:
When running simulations in the Simulink^{®} 
The parameters on the Data Types pane of the block dialog are only used for complex fixedpoint inputs. The sum of the squares of the real and imaginary parts of such an input are formed before a comparison is made, as described in Value Mode. The results of the squares of the real and imaginary parts are placed into the product output data type. The result of the sum of the squares is placed into the accumulator data type. These parameters are ignored for other types of inputs.
In the following ex_maximum_ref model,
the Maximum block calculates the running maximum of a 3by2 matrix
input, dsp_examples_u
. The Input processing parameter
is set to Columns as channels (frame based)
,
so the block processes the input as a two channel signal with a frame
size of three. The running maximum is reset at t=2
by an impulse to the block's Rst port.
The operation of the block is shown in the following figure.
The Main pane of the Maximum block dialog appears as follows.
Specify the block's mode of operation:
Value
— Output the
maximum value of each input
Index
— Output the
index of the maximum value
Value and index
—
Output both the value and the index
Running
— Track
the maximum value of the input sequence over time
For more information, see Description.
Specify how the block should process the input when computing the running maximum. You can set this parameter to one of the following options:
Columns as channels (frame based)
—
When you select this option, the block treats each column of the input
as a separate channel.
Elements as channels (sample based)
—
When you select this option, the block treats each element of the
input as a separate channel.
This parameter appears only when you set the Mode to Running
.
Note:
The option 
Specify whether the index of the maximum value is reported using
onebased or zerobased numbering. This parameter is only visible
when the Mode parameter is set to Index
or Value
and index
.
Specify whether to find the maximum value along rows, columns, entire input, or the dimension specified in the Dimension parameter. For more information, see Description.
Specify the reset event that causes the block to reset the running
maximum. The sample time of the input to the Rst port must be a positive
integer multiple of the input sample time. This parameter appears
only when you set the Mode parameter to Running
.
For information about the possible values of this parameter, see Resetting the Running Maximum.
Specify the dimension (onebased value) of the input signal,
over which the maximum is computed. The value of this parameter cannot
exceed the number of dimensions in the input signal. This parameter
is only visible when the Find the maximum value over parameter
is set to Specified dimension
.
The Data Types pane of the Maximum block dialog appears as follows.
Note: The parameters on the Data Types pane are only used for complex fixedpoint inputs. The sum of the squares of the real and imaginary parts of such an input are formed before a comparison is made, as described in Value Mode. The results of the squares of the real and imaginary parts are placed into the product output data type. The result of the sum of the squares is placed into the accumulator data type. These parameters are ignored for other types of inputs. 
Select the rounding mode for fixedpoint operations.
When you select this check box, the block saturates the result
of its fixedpoint operation. When you clear this check box, the block
wraps the result of its fixedpoint operation. By default, this check
box is cleared. For details on saturate
and wrap
,
see overflow
mode for fixedpoint operations.
Specify the product output data type. See FixedPoint Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block. You can set it to:
A rule that inherits a data type, for example, Inherit:
Same as input
An expression that evaluates to a valid data type,
for example, fixdt([],16,0)
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Product output data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
Specify the accumulator data type. See FixedPoint Data Types for illustrations depicting the use of the accumulator data type in this block. You can set this parameter to:
A rule that inherits a data type, for example, Inherit:
Same as product output
An expression that evaluates to a valid data type,
for example, fixdt([],16,0)
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Accumulator data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
Select this parameter to prevent the fixedpoint tools from overriding the data types you specify on the block mask.
This block supports HDL code generation using HDL Coder™. HDL Coder provides additional configuration options that affect HDL implementation and synthesized logic. For more information on implementations, properties, and restrictions for HDL code generation, see Maximum.
Port  Supported Data Types 

Input 

Reset 

Idx 

Val 

Mean  DSP System Toolbox 
Minimum  DSP System Toolbox 
MinMax  Simulink 
max  MATLAB 
dsp.Maximum  DSP System Toolbox 