Engee documentation

First Order Hold

Linearly extrapolated first-order retention for the input signal.

first order hold

Description

The First Order Hold block generates a continuous piecewise linear approximation of the input signal.

Use the First Order Hold block to convert a discrete signal into a continuous signal without additional solver settings.

You can also use First Order Hold to break algebraic loops in your model.

Ports

Input

Port 1 - input signal
scalar | vector | matrix | N-dimensional array

An input signal specified as a real scalar, vector or matrix.

  • Data types: Float16, Float 32, Float64, Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64, Bool.

Output

Port 1 - linearly approximated output signal
scalar | vector | matrix | N-dimensional array

Piecewise linear approximation of the input signal.

Data types: Float64.

Parameters

Initial output - initial output
0 (by default) | scalar | vector | N-dimensional array

Specify the output value that the block generates until the simulation time exceeds the first sampling time of the discrete input.

Dependencies

  • The initial output of this block cannot be inf or NaN.

Usage in program code

Block parameter

InitialOutput

Value

scalar | vector | N-dimensional array

By default

0

Output algorithm - output approximation method
Slow (Avoid Overshoot) (By default) | Fast (Minimise Error)

Specify the approximation method used to generate the output signal.

The slow low frequency algorithm (Slow (Avoid Overshoot)) avoids an output signal that does not match the input signal.

The fast high frequency algorithm Fast (Minimise Error) minimizes the error in the approximated output signal, but may result in an output signal that does not match the input signal.

Usage in program code

Block parameter

OutputAlgorithm

Type

string

Value

Slow (Avoid Overshoot) | Fast (Minimise Error)

* By default*

Slow (Avoid Overshoot)

Reset if relative extrapolation error exceeds - allowable error when resetting the solver
Inf (by default) | non-negative real scalar | vector

Specify the tolerance level for the extrapolation error of the inference algorithm.

The Inf value for the Allow continuous input parameter may lead to numerical inaccuracies in the simulation.
Usage in program code

Block parameter

ErrorTolerance

Type

character vector

Value

scalar | vector

By default

Inf

Allow continuous input - allow continuous signals
off (by default) | on

Select this option to allow the unit to accept continuous signals as input.

Enabling this parameter creates a delay between the input and output continuous signals.

Enable this option if you are using this unit to break algebraic loops.
Usage in program code

Block parameter

AllowContinuousInput

Value

off| on

* By default*

off

Algorithms

Slow (Avoid overshoot)

Linear extrapolation performed by a slow or low frequency algorithm can be described as:

where

  • - is the time at -th major step;

  • - input signal at -th large step;

  • and - linear extrapolation coefficients;

  • - continuous output signal at time .

The coefficients (slope angle and -delay ) are calculated as follows:







Fast (Minimize Error)

Linear extrapolation performed by a fast, or high-frequency, algorithm can be described as:

where

  • - is the time at -th major step;

  • - input at -m major step;

  • - predicted value of the input signal at -m major step;

  • and - linear extrapolation coefficients;

  • - continuous output signal at the moment of time .

The coefficients (slope and -delay ) are calculated as follows:













The fast algorithm minimises the error by trying to predict the next input signal while calling the block update method. The error minimisation in the predicted block output is compensated by the tendency to overestimate the input signal.