MATLAB: How to scale/normalize values in a matrix to be between -1 and 1

matrixnormnormalize

I found the script that scale/normalize values in a matrix to be between 0 and 1
I = [ 1 2 3; 4 5 6]; % Some n x m matrix I that contains unscaled values.
scaledI = (I-min(I(:))) ./ (max(I(:)-min(I(:))));
min(scaledI(:)) % the min is 0
max(scaledI(:)) % the max 1
Was wondering if anyone could help me normalize values in matrix between -1 and +1 Thanks

Best Answer

Once you have your result:
scaledl = scaledl.*2 - 1;
Or directly:
result = -1 + 2.*(data - min(data))./(max(data) - min(data));