Compute the rank of a matrix.


In the Julia programming language, the function rank(M) is used to compute the rank of a matrix M.

  1. Compute the rank of a matrix:

    julia> A = [1 2 3; 4 5 6; 7 8 9];
    julia> rank(A)

    This example calculates the rank of the matrix A, which is 2.

  2. Rank of a 1x1 matrix:

    julia> B = [10];
    julia> rank(B)

    When the matrix B is a 1x1 matrix, its rank is 1.

  3. Rank of a zero matrix:
    julia> C = zeros(3, 4);
    julia> rank(C)

    The rank of a zero matrix is always 0.

Common mistake example:

julia> D = [1 2 3; 4 5 6; 7 8 9];
julia> rank(D, 2)
ERROR: MethodError: no method matching rank(::Array{Int64,2}, ::Int64)

In this example, an additional argument 2 is provided to the rank function. However, the rank function does not accept any additional arguments. It is important to use the function according to its defined signature to avoid such errors.

See Also

Ac_ldiv_B, Ac_ldiv_Bc, Ac_mul_B, Ac_mul_Bc, Ac_rdiv_B, Ac_rdiv_Bc, At_ldiv_B, At_ldiv_Bt, At_mul_B, At_mul_Bt, At_rdiv_B, At_rdiv_Bt, A_ldiv_Bc, A_ldiv_Bt, A_mul_B!, A_mul_Bc, A_mul_Bt, A_rdiv_Bc, A_rdiv_Bt, Bidiagonal, cond, conv2, det, diag, diagind, diagm, diff, eig, eigvals, eigvecs, expm, eye, full, inv, isdiag, ishermitian, isposdef, isposdef!, issym, istril, istriu, logabsdet, logdet, lyap, norm, qrfact, rank, repmat, rot180, rotl90, rotr90, sortrows, sqrtm, SymTridiagonal, trace, Tridiagonal, tril, tril!, triu, triu!, writedlm,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: