Main Content

der

Return time derivative of operand

Syntax

der(x)
x.der

Description

The equations section may contain der operator, which returns the time derivative of its operand:

der(x) = x.der = x˙ = dxdt

der operator takes any numerical expression as its argument:

  • der applied to expressions that are continuous returns their time derivative

  • der applied to time argument returns 1

  • der applied to expressions that are parametric or constant returns 0

  • der applied to countable operands returns 0. For example, der(a<b) returns 0 even if a and b are variables.

The return unit of der is the unit of its operand divided by seconds.

You can nest der operators to specify higher order derivatives. For example, der(der(x))is the second order time derivative of x.

The following restrictions apply:

  • You cannot form nonlinear expressions of the output from der. For example, der(x)*der(x) would produce an error because this is no longer a linearly implicit system.

  • For a component to compile, the number of differential equations should equal the number of differential variables.

Examples

This example shows implementation for a simple dynamic system:

x˙=1x

The Simscape™ file looks as follows:

component MyDynamicSystem
  variables
    x = 0;
  end
  equations
    x.der == (1 - x)*{ 1, '1/s' };  % x' = 1 - x
  end
end

The reason you need to multiply by { 1, '1/s' } is that (1-x) is unitless, while the left-hand side (x.der) has the units of 1/s. Both sides of the equation statement must have the same units.

Version History

Introduced in R2008b

See Also