How to Normalize in Matlab

Written by michael carroll
  • Share
  • Tweet
  • Share
  • Email

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).

Skill level:
Moderately Easy

Other People Are Reading

Instructions

  1. 1

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

    v = [1 4 17 2 9 5 5]

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

  2. 2

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

    v = v/norm(v)

  3. 3

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

    norm(v)

Tips and warnings

  • 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.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.