Scale

(Engine-Level Function)

Description: Returns a value that has been converted from one scale to another.
Returns: Numeric
Usage: Script or steady state.
Function Groups: Generic Math
Related to: Normalize | Cond | Limit | Step
Format:  Scale(Value, In1, In2, Out1, Out2)
Parameters:  
Value
Required. Any numeric expression giving the value to be scaled.
In1
Required. Any numeric expression giving the minimum of Value's unscaled range. This parameter corresponds to Out1. This is usually the "zero" for the unscaled Value.
In2
Required. Any numeric expression giving the maximum of Value's unscaled range. This parameter corresponds to Out2. In2 must not equal In1.
Out1
Required. Any numeric expression giving the minimum of Value's scaled output range. This parameter corresponds to In1. This is usually the "zero" for the scaled Value.
Out2
Required. Any numeric expression giving the maximum of Value's scaled output range. This parameter corresponds to In2.
Comments: This function may be used in combination with Cond to perform piecewise linearization of a value or expression. Limit may be used to keep the result within bounds.
The compiler will reduce this function to a constant if all of its parameters evaluate to constants.

Examples:

Suppose the top edge of a bar on the screen is to go from 10 to 527 for a corresponding process value change of -50 to +100. The scale function parameters would be :

Scale(Value, -50, 100, 10, 527);

It should be noted that the Value parameter need not remain within the range of In1 to In2 for the result to be valid. For example, to convert from Fahrenheit to Celsius temperature scales :

Celsius = Scale(Fahrenheit, 32, 212, 0, 100);

This means that 32 F = 0 C and 212 F = 100 C. If the temperature were outside the range of 32 to 212, the resulting Celsius temperature would still be correct.