Main Content

cond

Condition number of matrix

Description

example

cond(A)returns the2-norm condition number of matrixA.

example

cond(A,P)returns theP-norm condition number of matrixA.

Examples

collapse all

Compute the2-norm condition number of the inverse of the 3-by-3 magic squareA.

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

Usevpato 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 squareA.

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 usingvpa.

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 usingcondandvpa.

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 values1,2,inf, or'fro'.

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

  • cond(A,2)orcond(A)returns the2-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. TheP-norm condition number of the matrixAis defined asnorm(A,P)*norm(inv(A),P).

Tips

  • Callingcondfor a numeric matrix that is not a symbolic object invokes the MATLAB®condfunction.

版本历史

Introduced in R2012b