Main Content

Rounding Function

R2026b

Apply rounding function to signal

  • Rounding Function block

Libraries:
Simulink / Math Operations

Description

The Rounding Function block rounds each element of the input signal to produce the output signal.

You select the type of rounding from the Function parameter list. The name of the selected function appears on the block.

Tip

Use the Rounding Function block when you want vector or matrix output.

Ports

Input

expand all

Input signal to which the rounding function is applied.

Data Types: single | double

Output

expand all

Output signal after the rounding function is applied to the input signal. The output signal has the same dimensions and data type as the input. Each element of the output signal is the result of applying the selected rounding function to the corresponding element of the input signal.

Data Types: single | double

Parameters

expand all

Choose the rounding function applied to the input signal.

Rounding functionRounds each element of the input signal
floorTo the nearest integer value towards minus infinity
ceilTo the nearest integer towards positive infinity
roundTo the nearest integer
fixTo the nearest integer towards zero

Programmatic Use

Block Parameter: Operator
Type: character vector
Values: 'floor' | 'ceil' | 'round' | 'fix'
Default: 'floor'

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

Block Characteristics

Data Types

double | single

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

yes

Zero-Crossing Detection

no

Programmatic Use: Add Block

To add the block programmatically, use the add_block function with one of these library block paths as the source.

"simulink/Math Operations/Rounding Function"

Example: add_block("simulink/Math Operations/Rounding Function","myModel/myBlock",MakeNameUnique="on")

For information about programmatic access to individual block parameters, see the Programmatic Use section of parameter descriptions on this page.

Extended Capabilities

expand all

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

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

Version History

Introduced before R2006a