We Value Your Privacy

We and our partners use technology such as cookies on our site to personalise content and ads, provide social media features, and analyse our traffic. Click below to consent to the use of this technology across the web. You can change your mind and change your consent choices at anytime by returning to this site.

Update Consent
Loading ...

How to Normalize in Matlab

Updated July 20, 2017

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

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

  2. v = [1 4 17 2 9 5 5]

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

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

  5. v = v/norm(v)

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

  7. norm(v)

  8. Tip

    This method could produce an error if the magnitude of the vector is 0 or extremely close to 0. This implies, however, that the vector does not have a meaningful direction, and normalising it would not be useful.

Loading ...

About the Author

Michael Carroll is a high school mathematics teacher. He has written for various websites since 2010, specializing in programming, web design, electronics and various pieces of software. He holds a bachelor's degree in electrical engineering from the University of Texas, with specialization in embedded system design.

Loading ...