How to Normalize a Matrix in MatLab

How to Normalize a Matrix in MatLab thumbnail
Normalization transforms data to a common scale.

MATLAB is an industry-standard for the development of analysis and simulation applications for scientific and technical data. Normalization, statistically, is a method of transforming data onto a common scale so that comparison across samples can be meaningful. It is common to transform values within a matrix so that values range between 0 and 1.

Instructions

    • 1

      Calculate the minimum of your matrix, and subtract it from all values.

      my_min = min( reshape( my_matrix, numel( my_matrix ), 1 ) );
      my_matrix = my_matrix - my_min;

    • 2

      Calculate the maximum of your matrix, and divide each value, element-wise, by the maximum.

      my_max = max( reshape( my_matrix, numel( my_matrix ), 1 ) );
      my_matrix = my_matrix ./ my_max;

    • 3

      Graph the histogram of values in your normalized matrix using the hist() function. Notice that values now range evenly between 0 and 1.

      hist( reshape( my_matrix, numel(my_matrix), 1), 25);

    • 4

      Divide your matrix by the 2-norm of the matrix to normalize to a mean of 0. Whether to you this or the above method depends on your intention.

      normalize_matrix = my_matrix/norm(my_matrix);

Tips & Warnings

  • There are many methods of applying normalization, and many meanings of normalization—when compared precisely. It is most important to normalize consistently.

Related Searches:

References

  • Photo Credit Jupiterimages/Photos.com/Getty Images

Comments

Related Ads

Featured