Derivative

Output time derivative of input

Library

Continuous

Description

The Derivative block approximates the derivative of the input signal u with respect to the simulation time t. You obtain the approximation of

dudt,

by computing a numerical difference Δu/Δt,where Δu is the change in input value and Δt is the change in time since the previous simulation (major) time step.

This block accepts one input and generates one output. The initial output for the block is zero.

The precise relationship between the input and output of this block is:

y(t)=ΔuΔt=u(t)u(Tprevious)tTprevious|t>Tprevious,

where t is the current simulation time and Tprevious is the time of the last output time of the simulation. The latter is the same as the time of the last major time step.

The Derivative block output might be very sensitive to the dynamics of the entire model. The accuracy of the output signal depends on the size of the time steps taken in the simulation. Smaller steps allow a smoother and more accurate output curve from this block. However, unlike with blocks that have continuous states, the solver does not take smaller steps when the input to this block changes rapidly. Depending on the dynamics of the driving signal and model, the output signal of this block might contain unexpected fluctuations. These fluctuations are primarily due to the driving signal output and solver step size.

Because of these sensitivities, structure your models to use integrators (such as Integrator blocks) instead of Derivative blocks. Integrator blocks have states that allow solvers to adjust step size and improve accuracy of the simulation. See Circuit Model for an example of choosing the best-form mathematical model to avoid using Derivative blocks in your models,

If you must use the Derivative block with a variable step solver, set the solver maximum step size settings to a value such that the Derivative block can generate answers with adequate accuracy. To determine this value, you might need to repeatedly run the simulation using different solver settings.

When the input to this block is a discrete signal, the continuous derivative of the input exhibits an impulse when the value of the input changes. Otherwise, it is 0. Alternatively, you can define the discrete derivative of a discrete signal using the difference of the last two values of the signal, as follows:

y(k)=1Δt(u(k)u(k1))

Taking the z-transform of this equation results in:

Y(z)u(z)=1z1Δt=z1Δtz.

The Discrete Derivative block models this behavior. Use this block instead of the Derivative bock to approximate the discrete-time derivative of a discrete signal.

Improved Linearization with Transfer Fcn Blocks

The Laplace domain transfer function for the operation of differentiation is:

Y(s)X(s)=s

This equation is not a proper transfer function, nor does it have a state-space representation. As such, the Simulink® software linearizes this block as an effective gain of 0 unless you explicitly specify that a proper first-order transfer function should be used to approximate the linear behavior of this block (see Coefficient c in the transfer function approximation s/(c*s + 1) used for linearization).

To improve linearization, you can also try to incorporate the derivative term in other blocks. For example, if you have a Derivative block in series with a Transfer Fcn block, try using a single Transfer Fcn block of the form

ss+a.

For example, you can replace the first set of blocks in this figure with the blocks below them.

Data Type Support

The Derivative block accepts and outputs a real signal of type double. For more information, see Data Types Supported by Simulink.

Parameters and Dialog Box

Coefficient c in the transfer function approximation s/(c*s + 1) used for linearization

Specify the time constant c to approximate the linearization of your system.

Settings

Default: inf

  • The exact linearization of the Derivative block is difficult, because the dynamic equation for the block is y=u˙, which you cannot represent as a state-space system. However, you can approximate the linearization by adding a pole to the Derivative to create a transfer function s/(cs+1). The addition of a pole filters the signal before differentiating it, which removes the effect of noise.

  • The default value inf corresponds to a linearization of 0.

Tips

  • A best practice is to change the value of c to1fb, where fb is the break frequency for the filter.

  • Coefficient c in the transfer function approximation s/(c*s+1) used for linearization must be a finite positive value. This value must be nonzero.

Command-Line Information

Parameter: CoefficientInTFapproximation
Type: string
Value: 'inf'
Default: 'inf'

Characteristics

Direct Feedthrough

Yes

Sample Time

Continuous

Scalar Expansion

N/A

Dimensionalized

Yes

Zero-Crossing Detection

No

Was this topic helpful?