NORM Norm Calculation

Section: Array Generation and Manipulations

Usage

Calculates the norm of a matrix. There are two ways to use the norm function. The general syntax is
   y = norm(A,p)

where A is the matrix to analyze, and p is the type norm to compute. The following choices of p are supported

For a vector, the regular norm calculations are performed:

Examples

Here are the various norms calculated for a sample matrix
--> A = float(rand(3,4))
A = 
  <float>  - size: [3 4]
 
Columns 1 to 4
 0.35852790  0.79405016  0.09099465  0.35239327  
 0.61784583  0.10321426  0.56628412  0.96009928  
 0.63974983  0.42631793  0.19367667  0.58536506  
--> norm(A,1)
ans = 
  <float>  - size: [1 1]
 1.8978577  
--> norm(A,2)
ans = 
  <float>  - size: [1 1]
 1.7248069  
--> norm(A,inf)
ans = 
  <float>  - size: [1 1]
 2.2474434  
--> norm(A,'fro')
ans = 
  <float>  - size: [1 1]
 1.8701774  

Next, we calculate some vector norms.

--> A = float(rand(4,1))
A = 
  <float>  - size: [4 1]
 
Columns 1 to 1
 0.37900960  
 0.14770868  
 0.74684000  
 0.96565938  
--> norm(A,1)
ans = 
  <double>  - size: [1 1]
 2.239217758178711  
--> norm(A,2)
ans = 
  <float>  - size: [1 1]
 1.2867533  
--> norm(A,7)
ans = 
  <double>  - size: [1 1]
 0.9871944436127973  
--> norm(A,inf)
ans = 
  <float>  - size: [1 1]
 0.9656594  
--> norm(A,-inf)
ans = 
  <float>  - size: [1 1]
 0.14770868