Main Content

der

Return time derivative of operand

Parent Section: equations

Syntax

der(x)

Description

The der operator returns the time derivative of its operand:

der(x) = x˙ = dxdt

Use the der operator in the equations section of a component or domain.

The 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

expand all

This example shows the implementation of a simple dynamic system:

x˙=1x

The complete Simscape™ file is:

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

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

Tips

  • x.der is equivalent to der(x), but not recommended. Use der(x) for code clarity. x.der can be removed in a future release.

Version History

Introduced in R2008b

See Also