MinMax - Output minimum or maximum input value - Simulink (original) (raw)

Output minimum or maximum input value

Libraries:
Simulink / Math Operations
HDL Coder / Math Operations

Description

The MinMax block outputs either the minimum or the maximum element or elements of the inputs. You choose whether the block outputs the minimum or maximum values by setting the Function parameter.

The MinMax block ignores any input value that is NaN, except when every input value is NaN. When all input values areNaN, the output is NaN, either as a scalar or the value of each output vector element.

Examples

expand all

This example shows how to use the MinMax block to output the maximum value of two sine waves.

After running the full simulation, you can view the results in the Scope. Initially, the maximum value (orange line) tracks SineWave2. When the SineWave2 values turn negative, the maximum value begins tracking SineWave1. When the SineWave2 values become positive again, the maximum value resumes tracking SineWave2.

Extended Examples

Ports

Input

expand all

Provide an input signal from which the block outputs the maximum or minimum values.

Dependencies

To support matrix input, you must set the Number of input ports parameter to an integer greater than one. All nonscalar inputs must have the same dimensions.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Provide an input signal from which the block outputs the maximum or minimum values.

When the block has multiple input ports, all nonscalar inputs must have the same dimensions. The block expands any scalar inputs to have the same dimensions as the nonscalar inputs. The block outputs a signal having the same dimensions as the input. Each output element equals the minimum or maximum of the corresponding input elements.

Dependencies

To provide more than one input signal, set the Number of input ports to an integer greater than 1.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Output

expand all

When the block has one input, the output is a scalar value, equal to the minimum or maximum of the input elements. When the block has multiple inputs, the output is a signal having the same dimensions as the input. Each output element equals the minimum or maximum of the corresponding input elements. If the block input has different input data types, the output is the same size as the input, but might have less precision. For example, if one input is int8 and one isuint8, the output data type is still 8 bits,sfix8_E1, but with less precision.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Parameters

expand all

Main

Specify whether to apply the function min ormax to the input.

Programmatic Use

Block Parameter: Function
Type: character vector
Values: 'min' | 'max'
Default: 'min'

Specify the number of inputs to the block.

Programmatic Use

Block Parameter: Inputs
Type: character vector
Values: positive integer
Default: '1'

Specify how to apply the function along specified dimensions.

For example, in this model, Function is set tomax, and Apply over is set to All dimensions. The block returns the largest input value from all dimensions.

2D matrix with Constant block value [1 3 5;3 6 7;9 10 1] as input to MinMax block configured for all dimensions

Dependencies

To enable this parameter, Number of input ports must be 1.

Programmatic Use

Block Parameter: CollapseMode
Type: character vector
Values: 'All dimensions' | 'Specified dimension'
Default: 'All dimensions'

Specify the dimension along which to apply the function as a positive integer. For example, for a 2-D matrix, 1 applies the function to each column, and 2 applies the function to each row.

For example, in this model, Function is set tomax, Apply over is set to Specified dimension, andDimension is set to 2. The block returns the largest input value from each row.

2D matrix with Constant block value [1 3 5;3 6 7;9 10 1] as input to MinMax block configured for dimension 2

Dependencies

To enable this parameter, set Apply over toSpecified dimension.

Programmatic Use

Block Parameter: CollapseDim
Type: character vector
Values: positive integer
Default: '1'

Select to enable zero-crossing detection. For more information, see Zero-Crossing Detection.

Programmatic Use

Block Parameter:ZeroCross
Type: character vector | string
Values: 'off' |'on'
Default: 'on'

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. For more information, see Specify Sample Time.

Dependencies

This parameter is visible only if you set it to a value other than-1. To learn more, see Blocks for Which Sample Time Is Not Recommended.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: SampleTime
Values: "-1" (default) | scalar or vector in quotes

Signal Attributes

Select this check box to require that all inputs have the same data type.

Programmatic Use

Block Parameter: InputSameDT
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Choose the data type for the output. The type can be inherited, specified directly, or expressed as a data type object such asSimulink.NumericType.

The Data Type Assistant helps you set data attributes. To use the Data Type Assistant, click the Show data type assistant button. For more information, see Specify Data Types Using Data Type Assistant.

Dependencies

When input is a floating-point data type smaller than single precision, the Inherit: Inherit via internal rule output data type depends on the setting of the Inherit floating-point output type smaller than single precision configuration parameter. Data types are smaller than single precision when the number of bits needed to encode the data type is less than the 32 bits needed to encode the single-precision data type. For example, half andint16 are smaller than single precision.

Programmatic Use

Block Parameter:OutDataTypeStr
Type: character vector
Values: 'Inherit: Inherit via internal rule' | 'Inherit: Inherit via back propagation' 'Inherit: Same as first input' 'double' 'single' 'half' 'int8' 'uint8' 'int16' 'uint16' 'int32' 'uint32' 'int64' 'uint64' 'fixdt(1,16,0)' 'fixdt(1,16,2^0,0)' ''
Default: 'Inherit: Inherit via internal rule'

Select this parameter to prevent the fixed-point tools from overriding theOutput data type you specify on the block. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: LockScale
Values: 'off' (default) | 'on'

Specify the rounding mode for fixed-point operations. For more information, see Rounding Modes (Fixed-Point Designer).

Block parameters always round to the nearest representable value. To control the rounding of a block parameter, enter an expression using a MATLAB® rounding function into the mask field.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RndMeth
Values: 'Floor' (default) | 'Ceiling' 'Convergent' 'Nearest' 'Round' 'Simplest' 'Zero'

Specify whether overflows saturate or wrap.

For example, the maximum value that the signed 8-bit integer int8 can represent is 127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer.

Tips

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: SaturateOnIntegerOverflow
Values: 'off' (default) | 'on'

Block Characteristics

Data Types Boolean | double fixed point half integer single
Direct Feedthrough yes
Multidimensional Signals yes
Variable-Size Signals yes
Zero-Crossing Detection yes

Extended Capabilities

expand all

HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.

HDL Architecture

Architecture Additional cycles of latency Description
Tree (default) 0 Generates a tree structure of comparators.

HDL Block Properties

General
ConstrainedOutputPipeline Number of registers to place at the outputs by moving existing delays within your design. Distributed pipelining does not redistribute these registers. The default is0. For more details, see ConstrainedOutputPipeline (HDL Coder).
InputPipeline Number of input pipeline stages to insert in the generated code. Distributed pipelining and constrained output pipelining can move these registers. The default is0. For more details, see InputPipeline (HDL Coder).
OutputPipeline Number of output pipeline stages to insert in the generated code. Distributed pipelining and constrained output pipelining can move these registers. The default is0. For more details, see OutputPipeline (HDL Coder).
Native Floating Point
LatencyStrategy Specify whether to map the blocks in your design toinherit, Max, Min, or Zero for the floating-point operator. The default isinherit. See also LatencyStrategy (HDL Coder).

Version History

Introduced before R2006a

expand all

The MinMax block enables you to find minimum or maximum values over a specified dimension using these new parameters: