next up previous contents
Next: NUMEL Number of Elements Up: Array Generation and Manipulations Previous: NONZEROS Retrieve Nonzero Matrix   Contents

Subsections

NORM Norm Calculation

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 3
    0.81472367         0.91337585         0.27849823      
    0.90579194         0.63235927         0.54688150      
    0.12698682         0.097540408        0.95750684      
 
Columns 4 to 4
    0.96488851      
    0.15761308      
    0.97059280      
--> norm(A,1)
ans = 
  <float>  - size: [1 1]
    2.0930943       
--> norm(A,2)
ans = 
  <float>  - size: [1 1]
    2.1609712       
--> norm(A,inf)
ans = 
  <float>  - size: [1 1]
    2.9714863       
--> norm(A,'fro')
ans = 
  <float>  - size: [1 1]
    2.4362614

Next, we calculate some vector norms.

--> A = float(rand(4,1))
A = 
  <float>  - size: [4 1]
 
Columns 1 to 1
    0.81472367      
    0.90579194      
    0.12698682      
    0.91337585      
--> norm(A,1)
ans = 
  <double>  - size: [1 1]
    2.760878324508667      
--> norm(A,2)
ans = 
  <double>  - size: [1 1]
    1.527944617361226      
--> norm(A,7)
ans = 
  <double>  - size: [1 1]
    1.034602949623434      
--> norm(A,inf)
ans = 
  <float>  - size: [1 1]
    0.91337585      
--> norm(A,-inf)
ans = 
  <float>  - size: [1 1]
    0.12698682


Samit K. Basu 2005-03-16