integ
Perform time integration of expression
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 containdelay
order
operators. Any time-dependency inexpr
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
Calculate the total energy through an electrical branch:
e == integ(v*i);
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 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