.BusinessSimulation.Functions.rescaleVector

Information

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

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

Syntax


Function.rescaleVector(x);                             // min = min(vec), max = max(vec), y_min = 0, y_max = 1
Function.rescaleVector(x, {min, max});                 // y_min = 0 , y_max = 1
Function.rescaleVector(x, {min, max}, {y_min, y_max});

Examples


rescaleVector({0,1,2,3,4,5,6,7,8,9,10});    // {0.,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0}
rescaleVector({4,5,6},{0, 10});             // {0.4, 0.5, 0.6}
rescaleVector({4,5,6},{0,10},{10,20});      // {14.,15.,16.}

Notes

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

See also

Functions.rescale

Interface

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

Revisions


Generated at 2024-12-21T19:25:56Z by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos