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.
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});
Function.rescale(5, {0, 10}); // 0.5
Function.rescale(5, {0, 10}, {10, 20}); // 15.
This function is closely modeled to Rescale in the Wolfram Language.
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;Inline = true in v2.1.0.