How to Normalize in Matlab

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.

To normalize a vector is to convert it to a unit vector (a vector of magnitude 1) that points in the same direction. Normalization is a common technique used to scale two data sets so they can be compared meaningfully. To quickly normalize a vector in MATLAB, divide it by the result of the "norm" function (its magnitude).

Advertisement

Step 1

Define the vector and store it in a variable with a command like this:

Video of the Day

v = [1 4 17 2 9 5 5]

You can use any variable name in place of "v."

Advertisement

Step 2

Divide your vector by its norm, and assign the result as the new value of the vector:

Advertisement

v = v/norm(v)

Step 3

Check the magnitude of the vector with "norm," and see that its magnitude is now 1:

norm(v)

Video of the Day

Advertisement

Advertisement

references