MATLAB: How to normalize negative values in column vector

negative valuesnormalization

Matlab 2015a
Hello, I have a column vector of 180 elements, with min(vector) = -1.6010 and max(vector) = 0.3894. when I apply normc(vector), and find min(vector) = -0.1318 and max(vetor) = 0.0321 for which I except the values to be in between 0 and 1. How to resolve this ??
When I am having positive values I do for ranging between 0 to 1
normalized_vector = (vector -min(vector)).max(vector);
but its not working with the negative values.

Best Answer

If you have the Image Processing Toolbox, you can simply use mat2gray:
normalizedVector = mat2gray(vector);
Now normalizedVector will go from 0 to 1. Otherwise, if you are so unfortunate as to not have one of the best toolboxes out there, just scale as you normally would:
normalizedVector = (vector - min(vector)) / (max(vector)-min(vector));
Related Question