Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

linalg::tr

Trace of a matrix

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

linalg::tr(A)

Description

linalg::tr(A) returns the trace of the square matrix A, i.e., the sum of the diagonal elements of A.

Examples

Example 1

We compute the trace of the following matrix:

A := Dom::Matrix(Dom::Integer)
  (3, 3, (i, j) -> 3*(i - 1) + j)

linalg::tr(A)

Parameters

A

A square matrix of a domain of category Cat::Matrix

Return Values

Element of the component ring of A.

Was this topic helpful?