Scale function

Scaling data fields


Description

The Scale function converts the values ​​of a data field to a new scale. The first parameter specified is the data field to be scaled. With two optional parameters, the new minimum and maximum can be specified.


Without specification of minimum and maximum

If no min and max arguments are specified, the new range is set to -1 to +1. The largest positive or negative value forms the maximum value -1 or +1. The other values ​​are calculated accordingly. The zero position is retained.


With indication of minimum and maximum

If the optional parameters min and max are specified, the smallest value is calculated to min and the largest to max when scaling. The zero line is usually shifted.


Syntax

Scale (v)

Scale (v, min, max)

Examples

Scale ([4,-2,0,1]) = 1 -0.5 0 0.25

Scale ([4,-2,0,1],-1,1) = 1 -1 0.3333 0

Scale ([4,-2,0,1],2,4) = 4 2 2.6667 3