| Signal Processing Blockset™ | ![]() |
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 floating-point, fixed-point, and Boolean inputs. Real fixed-point inputs can be either signed or unsigned, while complex fixed-point 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.
The frame status of the block output is the same as that of the input, except when the Find the maximum value of parameter is set to Entire input. The output is always sample based when Entire input is selected.
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 3-dimensional input signal of size M-by-N-by-P:
Each row — The output at each sample time consists of an M-by-1-by-P array, where each element contains the maximum value of each vector over the second dimension of the input. For an input that is an M-by-N matrix, the output at each sample time is an M-by-1 column vector. In this mode, the frame status of the output is the same as that of the input.
Each column — The output at each sample time consists of a 1-by-N-by-P array, where each element contains the maximum value of each vector over the first dimension of the input. For an input that is an M-by-N matrix, the output at each sample time is a 1-by-N row vector. In this mode, the frame status of the output is the same as that of the input.
For convenience, length-M 1-D vector inputs are treated as M-by-1 column vectors when the block is in this mode. Sample-based length-M row vector inputs are also treated as M-by-1 column vectors when the Treat sample-based row input as a column check box is selected.
Entire input — The output at each sample time is a scalar that contains the maximum value in the M-by-N-by-P input matrix. In this mode, the block output is always sample based.
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 M-by-N matrix containing the maximum value of each vector over the third dimension of the input. In this mode, the frame status of the output is the same as that 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
, the magnitude squared is
.

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 3-dimensional input signal of size M-by-N-by-P:
Each row — The output at each sample time consists of an M-by-1-by-P 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 M-by-N matrix, the output at each sample time is an M-by-1 column vector. In this mode, the frame status of the output is the same as that of the input.
Each column — The output at each sample time consists of a 1-by-N-by-P 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 M-by-N matrix, the output at each sample time is an M-by-1 column vector. In this mode, the frame status of the output is the same as that of the input.
For convenience, length-M 1-D vector inputs are treated as M-by-1 column vectors when the block is in this mode. Sample-based length-M row vector inputs are also treated as M-by-1 column vectors when the Treat sample-based row input as a column check box is selected.
For an input that is an M-by-N matrix, the output at each sample time is an M-by-1 column vector.
Entire input — The output at each sample time is a 1-by-3 vector that contains the location of the maximum value in the M-by-N-by-P input matrix. In this mode, the block output is always sample based. For an input that is an M-by-N matrix, the output will be a 1-by-2 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 M-by-N matrix containing the indices of the maximum values of each vector over the third dimension of the input. In this mode, the frame status of the output is the same as that 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 one-based index of the maximum value is 1 rather than 5 when Each column is selected.
When inputs to the block are double-precision values, the index values are double-precision values. Otherwise, the index values are 32-bit 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 M-by-N inputs. For sample-based inputs, the output is a sample-based M-by-N array with each element yij containing the maximum value observed in element uij for all inputs since the last reset. For frame-based inputs, the output is a frame-based M-by-N matrix with each element yij containing the maximum value observed in the jth column of all inputs since the last reset, up to and including element uij of the current input.
N-D signals cannot be frame based. When the block is set to Running mode,
each element of the N-D signal is treated as a separate channel. There
are
channels, where di is
the size of the ith dimension.
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.
For sample-based inputs, a reset event causes the running maximum for each channel to be initialized to the value in the corresponding channel of the current input. For frame-based inputs, a reset event causes the running maximum for each channel to be 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)
Non-zero sample — Triggers a reset operation at each sample time that the Rst input is not zero
Note When running simulations in the Simulink MultiTasking mode, reset signals have a one-sample latency. Therefore, when the block detects a reset event, there is a one-sample delay at the reset port rate before the block applies the reset. For more information on latency and the Simulink tasking modes, see Excess Algorithmic Delay (Tasking Latency) and Models with Multiple Sample Rates in the Real-Time Workshop User's Guide. |
To calculate the statistical value within a particular region of interest (ROI) of the input, select the Enable ROI processing check box. This option is only available when the Find the maximum value over parameter is set to Entire input and the Enable ROI processing check box is selected. ROI processing is only supported for 2-D inputs.
Note Full ROI processing is only available to users who have a Video and Image Processing Blockset license. If you only have a Signal Processing Blockset license, you can still use ROI processing, but are limited to the ROI type Rectangles. |
Use the ROI type parameter to specify whether the ROI is a rectangle, line, label matrix, or binary mask. A binary mask is a binary image that enables you to specify which pixels to highlight, or select. In a label matrix, pixels equal to 0 represent the background, pixels equal to 1 represent the first object, pixels equal to 2 represent the second object, and so on. When the ROI type parameter is set to Label matrix, the Label and Label Numbers ports appear on the block. Use the Label Numbers port to specify the objects in the label matrix for which the block calculates statistics. The input to this port must be a vector of scalar values that correspond to the labeled regions in the label matrix. For more information about the format of the input to the ROI port when the ROI is a rectangle or a line, see the Draw Shapes block reference page.
For rectangular ROIs, use the ROI portion to process parameter to specify whether to calculate the statistical value for the entire ROI or just the ROI perimeter.
Use the Output parameter to specify the block output. The block can output separate statistical values for each ROI or the statistical value for all specified ROIs. This parameter is not available if, for the ROI type parameter, you select Binary mask.
If, for the ROI type parameter, you select Rectangles or Lines, the Output flag indicating if ROI is within image bounds check box appears in the dialog box. If you select this check box, the Flag port appears on the block. The following tables describe the Flag port output based on the block parameters.
Output = Individual statistics for each ROI
| Flag Port Output | Description |
|---|---|
| 0 | ROI is completely outside the input image. |
| 1 | ROI is completely or partially inside the input image. |
Output = Single statistic for all ROIs
| Flag Port Output | Description |
|---|---|
| 0 | All ROIs are completely outside the input image. |
| 1 | At least one ROI is completely or partially inside the input image. |
If the ROI is partially outside the image, the block only computes the statistical values for the portion of the ROI that is within the image.
If, for the ROI type parameter, you select Label matrix, the Output flag indicating if input label numbers are valid check box appears in the dialog box. If you select this check box, the Flag port appears on the block. The following tables describe the Flag port output based on the block parameters.
Output = Individual statistics for each ROI
| Flag Port Output | Description |
|---|---|
| 0 | Label number is not in the label matrix. |
| 1 | Label number is in the label matrix. |
Output = Single statistic for all ROIs
| Flag Port Output | Description |
|---|---|
| 0 | None of the label numbers are in the label matrix. |
| 1 | At least one of the label numbers is in the label matrix. |
The parameters on the Fixed-point pane of the block dialog are only used for complex fixed-point 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.
The Maximum block in the following model calculates the running maximum of a frame-based 3-by-2 (two-channel) matrix input, u. The running maximum is reset at t=2 by an impulse to the block's Rst port.

The Maximum block has the following settings:
Mode = Running
Reset port = Non-zero signal
The Signal From Workspace block has the following settings:
Signal = u
Sample time = 1/3
Samples per frame = 3
where
u = [6 1 3 -7 2 5 8 0 -1 -3 2 1;1 3 9 2 4 1 6 2 5 0 4 17]'
The Discrete Impulse block has the following settings:
Delay (samples) = 2
Sample time = 1
Samples per frame = 1
The block's operation is shown in the figure below.

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 whether the index of the maximum value is reported using one-based or zero-based 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.
Select to treat sample-based length-M row vector inputs as M-by-1 column vectors. This parameter is only visible when the Find the maximum value of parameter is set to Each column.
Specify the reset event detected at the Rst input port when you select Running for the Mode parameter. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input. For information about the possible values of this parameter, see Resetting the Running Maximum.
Specify the dimension (one-based 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.
Select this check box to calculate the statistical value within a particular region of each image. This parameter appears only when you set the Find the maximum value over parameter to Entire input, and the block is not in running mode.
Note Full ROI processing is only available to users who have a Video and Image Processing Blockset license. If you only have a Signal Processing Blockset license, you can still use ROI processing, but are limited to the ROI type Rectangles. |
The ROI processing parameters appear on the dialog box as follows.

Specify the type of ROI you want to use. Your choices are Rectangles, Lines, Label matrix, or Binary mask.
Specify whether you want to calculate the statistical value for the entire ROI or just the ROI perimeter. This parameter appears only if you specify an ROI type of Rectangles.
Specify the block output. The block can output a vector of separate statistical values for each ROI or a scalar value that represents the statistical value for all the specified ROIs. This parameter is not available if, for the ROI type parameter, you select Binary mask.
If you select this check box, the Flag port appears on the block. For a description of the Flag port output, see the tables in ROI Processing. This parameter appears if you select an ROI type of Rectangles or Lines.
The Fixed-point pane of the Maximum block dialog appears as follows.

Note The parameters on the Fixed-point pane are only used for complex fixed-point 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 fixed-point operations.
Select the overflow mode for fixed-point operations.
Use this parameter to specify how you would like to designate the product output word and fraction lengths resulting from a complex-complex multiplication in the block. See Multiplication Data Types for more information:
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. This block requires power-of-two slope and a bias of zero.
Use this parameter to specify the accumulator word and fraction lengths resulting from a complex-complex multiplication in the block. See Multiplication Data Types for more information:
When you select Same as product output, these characteristics match those of the product output.
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. This block requires power-of-two slope and a bias of zero.
Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling feature of the Fixed-Point Tool. See the fxptdlg reference page for more information.
| Port | Supported Data Types |
|---|---|
Input |
|
Reset |
|
Idx |
|
Val |
|
| Mean | Signal Processing Blockset |
| Minimum | Signal Processing Blockset |
| MinMax | Simulink |
| max | MATLAB |
![]() | Matrix Viewer | Mean | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |