Main Content

normr

Normalize rows of matrix

Description

example

normalized_M = normr(M) takes a single matrix or cell array of matrices, M, and returns the matrices with rows normalized to a length of one.

Examples

collapse all

This example shows how to use the normr function to normalize the rows of a matrix.

Create a 2x2 matrix and call the normr function to normalize its rows to a length of 1.

m = [1 2; 3 4];
normr(m)
ans =
      0.4472     0.8944
      0.6000     0.8000
ans =
      0.4472     0.8944
      0.6000     0.8000

Input Arguments

collapse all

Matrix to normalize, specified as a matrix or a cell array of matrices.

Output Arguments

collapse all

Normalized matrix, returned as a matrix or a cell array of matrices.

Version History

Introduced before R2006a

See Also