.BusinessSimulation.Functions.rescale

Information

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

The function will rescale the input to run from range y_min to y_max over the range min to max.

Syntax


Function.rescale(x, {x_min, x_max});                 // {y_min, y_max} by default assumed to be {0,1}
Function.rescale(x, {min, max}, {y_min, y_max}); 

Examples


Function.rescale(5, {0, 10});                 // 0.5
Function.rescale(5, {0, 10}, {10, 20}); // 15.

Notes

This function is closely modeled to Rescale in the Wolfram Language.

See also

Functions.rescaleVector

Interface

function rescale
  extends BusinessSimulation.Icons.Function;
  input Real x "Value to be transformed";
  input Real x_range[2] "Original range [min,max] given as a list";
  input Real y_range[2] = {0, 1} "Rescaled range [y_min, y_max] given as a list (default = {0,1})";
  output Real y "Rescaled value to run from y_min to y_max over the range min to max";
end rescale;

Revisions


Generated at 2024-11-23T19:25:52Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos