Accelerating the pace of engineering and science

# issymmetric

Determine if matrix is symmetric or skew-symmetric

## Description

example

tf = issymmetric(A) returns logical 1 (true) if square matrix A is symmetric; otherwise, it returns logical 0 (false).

example

tf = issymmetric(A,skewOption) specifies the type of the test. Specify skewOption as 'skew' to determine if A is skew-symmetric.

## Examples

expand all

### Test if Hermitian Matrix Is Symmetric

Create a 3-by-3 matrix.

`A = [1 0 1i; 0 1 0;-1i 0 1]`
```A =

1.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 1.0000i
0.0000 + 0.0000i   1.0000 + 0.0000i   0.0000 + 0.0000i
0.0000 - 1.0000i   0.0000 + 0.0000i   1.0000 + 0.0000i```

The matrix is Hermitian and has a real-valued diagonal.

Test whether the matrix is symmetric.

`tf = issymmetric(A)`
```tf =

0```

The result is logical 0 (false) because A is not symmetric. In this case, A is equal to its complex conjugate transpose, A', but not its nonconjugate transpose, A.'.

Change the element in A(3,1) to be 1i.

`A(3,1) = 1i;`

Determine whether the modified matrix is symmetric.

`tf = issymmetric(A)`
```tf =

1```

The matrix, A, is now symmetric because it is equal to its nonconjugate transpose, A.'.

### Test if Matrix Is Skew-Symmetric

Create a 4-by-4 matrix.

`A = [0 1 -2 5; -1 0 3 -4; 2 -3 0 6; -5 4 -6 0]`
```A =

0     1    -2     5
-1     0     3    -4
2    -3     0     6
-5     4    -6     0```

The matrix is real and has a diagonal of zeros.

Specify skewOption as 'skew' to determine whether the matrix is skew-symmetric.

`tf = issymmetric(A,'skew')`
```tf =

1```

The matrix, A, is skew-symmetric since it is equal to the negation of its nonconjugate transpose, -A.'.

## Input Arguments

expand all

### A — Input matrixnumeric matrix

Input matrix, specified as a numeric matrix. If A is not square, then issymmetric returns logical 0 (false).

Data Types: single | double
Complex Number Support: Yes

### skewOption — Test type'nonskew' (default) | 'skew'

Test type, specified as 'nonskew' (default) or 'skew'. Specify 'skew' to test whether A is skew-symmetric. Specifying issymmetric(A,'nonskew') is equivalent to issymmetric(A).

Data Types: char

expand all

### Symmetric Matrix

• A square matrix, A, is symmetric if it is equal to its nonconjugate transpose, A = A.'.

In terms of the matrix elements, this means that

${a}_{i,\text{\hspace{0.17em}}j}={a}_{j,\text{\hspace{0.17em}}i}\text{\hspace{0.17em}}\text{\hspace{0.17em}}.$

• Since real matrices are unaffected by complex conjugation, a real matrix that is symmetric is also Hermitian. For example, the matrix

$A=\left[\begin{array}{cc}\begin{array}{cc}\begin{array}{c}1\\ 0\end{array}& \begin{array}{c}0\\ 2\end{array}\end{array}& \begin{array}{c}1\\ 0\end{array}\\ \begin{array}{cc}1& 0\end{array}& 1\end{array}\right]$

is both symmetric and Hermitian.

### Skew-Symmetric Matrix

• A square matrix, A, is skew-symmetric if it is equal to the negation of its nonconjugate transpose, A = -A.'.

In terms of the matrix elements, this means that

${a}_{i,\text{\hspace{0.17em}}j}=-{a}_{j,\text{\hspace{0.17em}}i}\text{\hspace{0.17em}}\text{\hspace{0.17em}}.$

• Since real matrices are unaffected by complex conjugation, a real matrix that is skew-symmetric is also skew-Hermitian. For example, the matrix

$A=\left[\begin{array}{cc}0& -1\\ 1& \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}0\end{array}\right]$

is both skew-symmetric and skew-Hermitian.