Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

MinMax

Output minimum or maximum input value

  • Library:
  • Simulink / 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 are NaN, the output is NaN, either as a scalar or the value of each output vector element.

Ports

Input

expand all

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

  • When the block has one input port, the input must be a scalar or a vector. The block outputs a scalar equal to the minimum or maximum element of the input vector.

  • 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 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: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | bus

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: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | bus

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.

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

Parameters

expand all

Main

Specify whether to apply the function min or max 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: '1'
Default: '1'

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

Programmatic Use

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

Specify the sample time as a value other than -1. For more information, see Specify Sample Time.

Dependencies

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

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar
Default: '-1'

Signal Attributes

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

Programmatic Use

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

Lower value of the output range that Simulink® checks.

Simulink uses the minimum to perform:

Note

Output minimum does not saturate or clip the actual output signal. Use the Saturation block instead.

Programmatic Use

Block Parameter: OutMin
Type: character vector
Values: '[ ]'| scalar
Default: '[ ]'

Upper value of the output range that Simulink checks.

Simulink uses the maximum value to perform:

Note

Output maximum does not saturate or clip the actual output signal. Use the Saturation block instead.

Programmatic Use

Block Parameter: OutMax
Type: character vector
Values: '[ ]'| scalar
Default: '[ ]'

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

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. See Specify Data Types Using Data Type Assistant for more information.

Programmatic Use

Block Parameter: OutDataTypeStr
Type: character vector
Values: 'Inherit: Inherit via internal rule' | 'Inherit: Inherit via back propagation' | 'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | '<data type expression>'
Default: 'Inherit: Inherit via internal rule'

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

Programmatic Use

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

For more information, see Rounding (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

Block Parameter: RndMeth
Type: character vector
Values: 'Ceiling' | 'Convergent' | 'Floor' | 'Nearest' | 'Round' | 'Simplest' | 'Zero'
Default: 'Floor'

Specify whether overflows saturate or wrap.

ActionRationaleImpact on OverflowsExample

Select this check box (on).

Your model has possible overflow, and you want explicit saturation protection in the generated code.

Overflows saturate to either the minimum or maximum value that the data type can represent.

The maximum value that the int8 (signed, 8-bit integer) data type can represent is 127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer. With the check box selected, the block output saturates at 127. Similarly, the block output saturates at a minimum output value of -128.

Do not select this check box (off).

You want to optimize efficiency of your generated code.

You want to avoid overspecifying how a block handles out-of-range signals. For more information, see Check for Signal Range Errors.

Overflows wrap to the appropriate value that is representable by the data type.

The maximum value that the int8 (signed, 8-bit integer) data type can represent is 127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer. With the check box cleared, the software interprets the overflow-causing value as int8, which can produce an unintended result. For example, a block result of 130 (binary 1000 0010) expressed as int8, is -126.

When you select this check box, saturation applies to every internal operation on the block, not just the output, or result. Usually, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.

Programmatic Use

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

Block Characteristics

Data Types

double | single | Boolean | base integer | fixed point

Multidimensional Signals

Yes

Variable-Size Signals

Yes

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Fixed-Point Conversion
Convert floating-point algorithms to fixed point using Fixed-Point Designer™.

Introduced before R2006a

Was this topic helpful?