"scale" numbers?



Assume that:

v = 1,...n

is a vector containing n real numbers.

Is there some procedure to "scale" all the numbers to lie in the range
[a;b]?


v = 1 2 3 4 5 6 7 8 9 10 11 12;
a = 1;
b = 8;

max_elm = max(v);
s = solve(max_elm/x = b);
frac = 1/s;
v_scaled = (v.*frac)+1

but the result is:

2 2 3 4 4 5
6 6 7 8 8 9

How is this done correctly and does it have a more formal name?


.