I have a range of values as [12,540 108 201,120 17] in an array.
I am going to convert these values in a range of [0 1] in MATLAB.
Is there any function in MATLAB?
Check mapminmax function from Neural Network Toolbox.
With this function you can map you data into [YMIN YMAX]
interval:
[Y,PS] = mapminmax(X,YMIN,YMAX)
It returns mapping parameters allowing you to use the same mapping with the new data:
Y = mapminmax('apply',X,PS)
or to revert the mapping to get your data back to the original space:
X = mapminmax('reverse',Y,PS)
But if you don't need to apply the same mapping twice or to revert it, then it's easier just to divide your data by the maximum value:
Y = (X - min(X)) / (max(X) - min(X))
Assuming all values are positive (as in your example) and the relationship between the variables in the original array and the [0 1] array is linear:
x = [12,540 108 201,120 17];
y = x/max(x);
[Y,PS] = mapminmax(X,0,1)
Define your variable as x
which can be matrix and use above comment in your code.