FUNCTION REFERENCE

rescale

Rescale data to an interval.

Rescale data to an interval.

Syntax

R = rescale(A)

Syntax

R = rescale(A, l, u)

Syntax

R = rescale(..., 'InputMin', inmin, 'InputMax', inmax)

Maps inmin to l and inmax to u linearly: l + (A - inmin)./(inmax - inmin).*(u - l), after values below inmin or above inmax are moved to those bounds. The defaults are l = 0, u = 1, and inmin and inmax the smallest and largest non-NaN values of the whole array. l, u, inmin and inmax may be scalars or arrays that expand along singleton dimensions (for example one value per column). Where inmin equals inmax (constant data) the result is l. NaN values stay NaN, and a NaN inmin or inmax gives NaN. Single input gives a single result; every other class (integer, logical) gives double.

Example

rescale([1 2 3 5])   % [0 0.25 0.5 1]

Example

rescale([-30 1 2 3 4 5 70], 'InputMin', 1, 'InputMax', 5)   % [0 0 0.25 0.5 0.75 1 1]

Differences from MATLAB: Real 2-D data only.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.