When calling norm on a matrix in MATLAB, it returns what’s known as a “matrix norm” (a scalar value), instead of an array of vector norms. Is there any way to obtain the norm of each vector in a matrix without looping and taking advantage of MATLAB’s vectorization?
When calling norm on a matrix in MATLAB, it returns what’s known as a
Share
You can compute the norm of each column or row of a matrix yourself by using element-wise arithmetic operators and functions defined to operate over given matrix dimensions (like SUM and MAX). Here’s how you could compute some column-wise norms for a matrix
M:These norms can easily be made to operate on the rows instead of the columns by changing the dimension arguments from
...,1to...,2.