Block Derivative approximates the derivative of the input signal by simulation time . The true value of the derivative it is approximated by the relation , where — the increment of the input signal, and — change in time since the previous (main) calculation step.
This unit accepts one input signal and outputs one output signal. The initial value of the output signal is zero.
The exact ratio between the input and output of the unit:
where
— current simulation time;
— the calculation time of the previous value, which coincides with the time of the last main time step.
Block output signal Derivative it can be sensitive to the dynamics of the entire model. The accuracy of the output signal depends on the step size of the model calculation. Smaller steps allow you to get a smoother and more accurate curve at the output of the block. However, unlike blocks that have continuous states, the solver does not perform smaller steps when the input data to this block is changing rapidly. Depending on the dynamics of the control signal and the model, the output signal of the unit may contain unexpected fluctuations. These fluctuations are primarily caused by the error of the output signal and the step size of the solver.
Because of these features, structure your models to use integrators (for example, blocks Integrator) instead of blocks Derivative. Blocks Integrator They have states that allow the solver to adjust the step size and improve the accuracy of the simulation.
If you need to use the block Derivative with a variable-step solver, then set the maximum step size of the solver to such a value that the block Derivative He could make calculations with sufficient accuracy. To determine this value, you may need to run the simulation several times with different solver settings.
If the input to this block is a discrete signal, then the continuous derivative of the input signal outputs a pulse when 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.:
The taking -transformations of this equation lead to:
Block Discrete Derivative simulates this behavior. Use this block instead of the block Derivative to approximate the time derivative of a discrete signal.