Main Content

integ

Perform time integration of expression

Parent Section: equations

Syntax

integ(expr,t_L)

Description

The integ operator lets you perform time integration of an expression in the equations section of a Simscape™ file without declaring and initializing extra variables.

The full syntax is:

integ(expr,t_L)

where:

  • expr is a Simscape language expression.

  • t_L is the lower integration limit, specified as a delay time relative to the current time. This operand is optional.

The upper integration limit is the current simulation time. If you omit the lower limit, the integration starts from the simulation start time.

expr can be of any type. It will automatically be converted to a double.

The following restrictions apply:

  • expr cannot contain delay or der operators. Any time-dependency in expr is attributed to the integration variable.

  • expr is assumed to have zero history for times prior to start of simulation.

  • t_L must be a scalar nonnegative constant or parametric expression with the unit of time.

The return unit of integ is the unit of its operand multiplied by a unit of time.

Examples

expand all

Calculate the total energy through an electrical branch:

p == v*i;      % power in Watt, J/s
e == integ(p); % s*J/s, energy in J

Calculate a moving average of the input signal:

component MovingAvg
  inputs
    u = 0;
  end
  outputs
    avg = 0;
  end
  parameters
    T = { 1, 's' };   % Time interval
  end
  equations
    assert(T>0);
    avg == integ(u,T)/T;
  end
end

The block generated from this component outputs the moving average of the input signal over a time interval specified by the Time interval parameter.

Version History

Introduced in R2016a

See Also