This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

cond

Condition number of matrix

Syntax

cond(A)
cond(A,P)

Description

example

cond(A) returns the 2-norm condition number of matrix A.

example

cond(A,P) returns the P-norm condition number of matrix A.

Examples

collapse all

Compute the 2-norm condition number of the inverse of the 3-by-3 magic square A.

A = inv(sym(magic(3)));
condN2 = cond(A)
condN2 =
(5*3^(1/2))/2

Use vpa to approximate the result.

vpa(condN2, 20)
ans =
4.3301270189221932338186158537647

Compute the 1-norm condition number, the Frobenius condition number, and the infinity condition number of the inverse of the 3-by-3 magic square A.

A = inv(sym(magic(3)));
condN1 = cond(A, 1)
condNf = cond(A, 'fro')
condNi = cond(A, inf)
condN1 =
16/3
 
condNf =
(285^(1/2)*391^(1/2))/60
 
condNi =
16/3

Approximate these results by using vpa.

vpa(condN1)
vpa(condNf)
vpa(condNi)
ans =
5.3333333333333333333333333333333
ans =
5.5636468855119361058627454652148
ans =
5.3333333333333333333333333333333

Hilbert matrices are examples of ill-conditioned matrices. Numerically compute the condition numbers of the 3-by-3 Hilbert matrix by using cond and vpa.

H = hilb(sym(3));
condN2 = vpa(cond(H))
condN1 = vpa(cond(H,1))
condNf = vpa(cond(H,'fro'))
condNi = vpa(cond(H,inf))
condN2 =
524.05677758606270799646154046059

condN1 =
748.0

condNf =
526.15882107972220183000899851322

condNi =
748.0

Input Arguments

collapse all

Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.

One of these values 1, 2, inf, or 'fro'.

  • cond(A,1) returns the 1-norm condition number.

  • cond(A,2) or cond(A) returns the 2-norm condition number.

  • cond(A,inf) returns the infinity norm condition number.

  • cond(A,'fro') returns the Frobenius norm condition number.

More About

collapse all

Condition Number of a Matrix

Condition number of a matrix is the ratio of the largest singular value of that matrix to the smallest singular value. The P-norm condition number of the matrix A is defined as norm(A,P)*norm(inv(A),P).

Tips

  • Calling cond for a numeric matrix that is not a symbolic object invokes the MATLAB® cond function.

Introduced in R2012b