cond
Condition number of matrix
Description
Examples
Compute 2-Norm Condition Number of Matrix
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 Different Condition Numbers of Matrix
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
Compute Condition Number of Hilbert Matrix
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
A
— Input
number | vector | matrix | array | symbolic number | symbolic variable | symbolic array | symbolic function | symbolic expression
Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.
P
— Input
2
(default) | number | character vector
One of these values 1
, 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
Tips
Calling
cond
for a numeric matrix that is not a symbolic object invokes the MATLAB®cond
function.
Version History
Introduced in R2012b
See Also
equationsToMatrix
| inv
| linsolve
| norm
| rank
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)