| Contents | Index |
Discrete
The Difference block outputs the current input value minus the previous input value.
The Difference block accepts signals of any numeric data type that Simulink supports, including fixed-point data types. For more information, see Data Types Supported by Simulink in the Simulink documentation.
The Main pane of the Difference block dialog box appears as follows:

Set the initial condition for the previous input.
Specify whether the block performs sample- or frame-based processing. You can select one of the following options:
Elements as channels (sample based) — Treat each element of the input as a separate channel (sample-based processing).
Columns as channels (frame based) — Treat each column of the input as a separate channel (frame-based processing).
Note Frame-based processing requires a DSP System Toolbox license. For more information, see Sample- and Frame-Based Concepts in the DSP System Toolbox documentation. |
Inherited — Inherit the processing mode from the input signal and delay the input accordingly. You can identify whether the input signal is sample or frame based by looking at the signal line. Simulink represents sample-based signals with a single line and frame-based signals with a double line.
Use Input processing to specify whether the block performs sample- or frame-based processing. The block accepts frame-based signals for the input u. All other input signals must be sample based.
| Input Signal u | Input Processing Mode | Block Works? |
|---|---|---|
| Sample based | Sample based | Yes |
| Frame based | No, produces an error | |
| Sample based | Frame based | Yes |
| Frame based | Yes | |
| Sample based | Inherited | Yes |
| Frame based | Yes |
For more information about these two processing modes, see Sample- and Frame-Based Concepts in the DSP System Toolbox documentation.
The Signal Attributes pane of the Difference block dialog box appears as follows:

Specify the minimum value that the block should output. The default value is [] (unspecified). Simulink software uses this value to perform:
Simulation range checking (see Signal Ranges)
Automatic scaling of fixed-point data types
Specify the maximum value that the block should output. The default value is[] (unspecified). Simulink software uses this value to perform:
Simulation range checking (see Signal Ranges)
Automatic scaling of fixed-point data types
Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via back propagation
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Output
data type parameter.
See Specifying Block Output Data Types for more information.
Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see Fixed-Point Tool and Fixed-Point Advisor in the Simulink Fixed Point documentation.
Specify the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink Fixed Point User's Guide.
Select to have overflows saturate to the maximum or minimum value that the data type can represent. Otherwise, overflows wrap.
When you select this check box, saturation applies to every internal operation on the block, not just the output or result. In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.
Direct Feedthrough | Yes |
Scalar Expansion | Yes, of inputs and gain |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |