Derivative
Output time derivative of input
 Library:
Simulink / 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
$$\frac{du}{dt},$$
by computing a numerical difference $$\Delta u/\Delta t,$$where $$\Delta u$$ is the change in input value and $$\Delta 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)=\frac{\Delta u}{\Delta t}=\frac{u(t)u({T}_{previous})}{t{T}_{previous}}t>{T}_{previous},$$
where t is the current simulation time and $${T}_{previous}$$ 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 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 for 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 the step size and improve simulation accuracy. See Circuit Model for an example of choosing the bestform 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 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.
If 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:
$$y(k)=\frac{1}{\Delta t}(u(k)u(k1))$$
.
Taking the ztransform of this equation results in:
$$\frac{Y(z)}{u(z)}=\frac{1{z}^{1}}{\Delta t}=\frac{z1}{\Delta t\cdot z}.$$
The Discrete Derivative block models this behavior. Use this block instead of the Derivative block to approximate the discretetime derivative of a discrete signal.
Ports
Input
Output
Parameters
Model Examples
Block Characteristics
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

Extended Capabilities
Version History
Introduced before R2006a