Engee documentation

Derivative

The time derivative of the input signal.

Derivative block

Description

The Derivative block approximates the derivative of the input signal over the simulation time . The true value of the derivative

,

is approximated by the relation , where is the increment of the input signal, and is the change in time since the previous (main) calculation step.

This block takes one input signal and produces one output signal. The initial value of the output signal is zero.

The exact relationship between the input and output of the block:

Where is the current simulation time, and is the computation time of the past value. The latter coincides with the time of the last main time step.

The output signal of the Derivative block can be sensitive to the dynamics of the whole model. The accuracy of the output signal depends on the size of the model calculation step. Smaller steps result in a smoother and more accurate curve at the block output. However, unlike blocks that have continuous states, Solver does not perform smaller steps when the input to this block changes rapidly. Depending on the dynamics of the control signal and the model, the block output may contain unexpected fluctuations. These fluctuations are primarily due to the error of the output signal and the step size of the solver.

Because of these features, structure your models to use integrators (e.g., Integrator blocks ) instead of Derivative blocks. The Integrator blocks have states that allow Solver to adjust the step size and improve the accuracy of the simulation.

If you need to use a Derivative block with Solver with variable step size, set the maximum step size of Solver to a value such that the Derivative block can make calculations with sufficient accuracy. You may need to run the simulation several times with different Solver settings to determine this value.

If the input to this block represents a discrete signal, the continuous derivative of the input signal produces a pulse as the value of the input signal changes. Otherwise, it is equal to 0. Alternatively, you can determine the discrete derivative of a discrete signal using the difference of the last two values of the signal:

Taking the z-transform of this equation leads to:

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

Ports

Input

Port_1 - input signal
real scalar or vector

Signal to be differentiated; scalar or vector.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool.

Output

Port_1 - time derivative of the input signal
real scalar or vector

The time derivative of the input signal; a scalar or vector. The input signal is differentiated in time as:

where is the current simulation time and is the computation time of the past value. The latter coincides with the time of the last main time step.

Data types: Float64.