.BusinessSimulation.Functions.interpolate

Information

This information is part of the Business Simulation Library (BSL). Please support this work and ► donate.

The output y is the interpolated value given a list of tuples (tuples = { {x1,y1}, {x2,y2}, ...}) and an index value jlo (default = 1) to guide the search. The function will also return the actual index value jsav used for the interpolation.

Syntax


Functions.interpolate(x, tuples);  // jlo = 1
Functions.interpolate(x, tuples, jlo);

Implementation

The index value jlo is used to guide the further procedure: If jlo == 1 then we assume that we are starting out a fresh search und accordingly locate() is used to come up with the correct index value to use for rawInterpolate().

If jlo > 1, then we assume to already have searched in the list of tuples and we can use the last index value to speed up the search; accordingly hunt will be used to find the new index value.

Examples


interpolate(1.5, {{0,1},{1,2}, {2,4},{3,5}}); // (3.0, 2)

See also

rawInterpolate, locate, hunt

Interface

encapsulated function interpolate
  import BusinessSimulation.Icons.Function;
  import BusinessSimulation.Functions.{rawInterpolate,hunt,locate};
  extends Function;
  input Real x "Value to locate in a list";
  input Real[:, 2] tuples "Ordered list of values";
  input Integer jlo = 1 "Index start value for the search";
  output Real y "Interpolated value";
  output Integer jsav "Index value used for the current interpolation";
end interpolate;

Revisions


Generated at 2024-04-28T18:16:21Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos