The norm function in Matlab is used to compute the Euclidean norm (magnitude) of a vector or the matrix norm.
For a vector v, the Euclidean norm is calculated using:
ā norm(v) = sqrt(sum(abs(v).^2))
For a matrix A, the matrix norm is calculated as:
ā norm(A) = sqrt(max(eig(A'*A)))
The code snippet below shows how to use the norm function to calculate the Euclidean norm of a vector 'v' and the matrix norm of a matrix 'A':
main.m214 chars12 lines
In this example, norm_v will have value 3.7417, while norm_A will have value 16.8481.
gistlibby LogSnag