Possible Duplicate:
MATLAB: how to normalize/denormalize a vector to range [-1;1]
Hi, just started using Matlab and I would like to know how to rescale the data in a matrix. I have a matrix of N rows by M columns and want to rescale the data in the columns to be between -1 and 1.
Each column contains values that vary in scale from say 0 - 10,000 to some that are between 0 and 1, the reason I want to normalise to between -1 and 1 as these values will be used in a Neural Network as input values for a transform function that is sine based.
A simple solution would use simple logic. Assuming that you mean to scale EACH column independently, do this:
Clearly this will result in the min for each column to be -1, the max will be 1. Code to do so is simple enough.
Now, perform the steps above to A.
Neither of the previous answers are correct. This is what you need to do:
The matrix
normalizedA
will have values between-1
and1
.Example: