issymmetricDetermine if a matrix is symmetric or skew-symmetric
A symmetric matrix
For all
and , it holds that , where is the element in -th row and -th column of .
A skew symmetric matrix
For all
and , it holds that , where is the element in -th row and -th column of .
This definition implies that all diagonal elements of
issymmetric(A)A should be a numeric matrix. If A is a character array, it will be converted to a double array.A is symmetric, it returns logical 1. Otherwise, it returns logical 0.A is empty, it returns logical 1.A is not square or ndims(A) > 2, it returns logical 0.issymmetric(A, skew)A should be a numeric matrix. If A is a character array, it will be converted to a double array.skew has to be a character array, equal to either 'skew' or 'nonskew'.isymmetric(A,'nonskew') gives the same result as isymmetric(A).isymmetric(A,'skew') gives logical 1 when A is skew symmetric.A is empty, it returns logical 1.A is not square or ndims(A) > 2, it returns logical 0.B is a real symmetric matrix.A = [1 2 3;4 5 6;7 8 9];
B = A+A'
issymmetric(B)
B =
2.000 6.000 10.00
6.000 10.00 14.00
10.00 14.00 18.00
ans =
1
A is complex and skew-symmetric.A = [1 2 3;4 5 6;7 8 9]+[1 2 3;4 5 6;7 8 9] * i;
A(1,1) = 0; A(2,2) = 0; A(3,3) = 0;
A(1,2) = -A(2,1);
A(1,3) = -A(3,1);
A(2,3) = -A(3,2)
issymmetric(A,'skew')
A =
0.000 + 0.000i -4.000 - 4.000i -7.000 - 7.000i
4.000 + 4.000i 0.000 + 0.000i -8.000 - 8.000i
7.000 + 7.000i 8.000 + 8.000i 0.000 + 0.000i
ans =
1