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.


Find rank of symbolic matrix





rank(A) returns the rank of symbolic matrix A.


Find Rank of Matrix

syms a b c d
A = [a b; c d];
ans =

Rank of Symbolic Matrices Is Exact

Symbolic calculations return the exact rank of a matrix while numeric calculations can suffer from round-off errors. This exact calculation is useful for ill-conditioned matrices, such as the Hilbert matrix. The rank of a Hilbert matrix of order n is n.

Find the rank of the Hilbert matrix of order 15 numerically. Then convert the numeric matrix to a symbolic matrix using sym and find the rank symbolically.

H = hilb(15);
ans =
ans =

The symbolic calculation returns the correct rank of 15. The numeric calculation returns an incorrect rank of 12 due to round-off errors.

Rank Function Does Not Simplify Symbolic Calculations

Consider this matrix


After simplification of 1-sin(x)^2 to cos(x)^2, the matrix has a rank of 1. However, rank returns an incorrect rank of 2 because it does not take into account identities satisfied by special functions occurring in the matrix elements. Demonstrate the incorrect result.

syms x
A = [1-sin(x) cos(x); cos(x) 1+sin(x)];
ans =

rank returns an incorrect result because the outputs of intermediate steps are not simplified. While there is no fail-safe workaround, you can simplify symbolic expressions by using numeric substitution and evaluating the substitution using vpa.

Find the correct rank by substituting x with a number and evaluating the result using vpa.

ans =

However, even after numeric substitution, rank can return incorrect results due to round-off errors.

Input Arguments

collapse all

Input, specified as a number, vector, or matrix or a symbolic number, vector, or matrix.

See Also

| |

Introduced before R2006a