Reputation: 137
I have a column vector (not evenly spaced) of size 10000 x 1, with a range of 1 to 7. I want to set new min and max values (min = 32, max = 72) and extrapolate the vales in between so previous values (1 to 7) now are within the new range (32 to 72).
Upvotes: 0
Views: 422
Reputation: 3802
A = 7*rand(10000,1);
B = (A-1)/6*(72-32)+32;
or in general:
minVal = 32;
maxVal = 72;
B = (A-min(A(:)))/(max(A(:))-min(A(:)))*(maxVal-minVal)+minVal;
Upvotes: 1
Reputation: 1214
Is this what you want?
old = [1 4 7];
new = (old - 1)/(7-1)*(72-32) + 32
result:
new =
32 52 72
Seems too easy, am I missing something? The example of turning 4 into 20/3 above makes me think that I am!
Upvotes: 1