issymmetric
Determine if matrix is symmetric or skew-symmetric
Description
tf = issymmetric(
returns logical
A
)1
(true
) if A
is a
symmetric matrix.
Otherwise, it returns logical 0
(false
).
tf = issymmetric(
specifies the type of the test. Specify A
,skewOption
)skewOption
as
"skew"
to determine if A
is skew-symmetric.
Examples
Test If Hermitian Matrix Is Symmetric
Create a 3-by-3 matrix.
A = [1 0 1i; 0 1 0;-1i 0 1]
A = 3×3 complex
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 if the matrix is symmetric.
tf = issymmetric(A)
tf = logical
0
The matrix A
is not symmetric because it is equal to its complex conjugate transpose, A'
, but not its nonconjugate transpose, A.'
.
Change the element in A(3,1)
to 1i
.
A(3,1) = 1i;
Test if the modified matrix is symmetric.
tf = issymmetric(A)
tf = logical
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 = 4×4
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.
Test if the matrix is skew-symmetric by specifying the test type as "skew"
.
tf = issymmetric(A,"skew")
tf = logical
1
The matrix A
is skew-symmetric because it is equal to the negation of its nonconjugate transpose, -A.'
.
Input Arguments
A
— Input array
array
Input array. If A
is not a square matrix, then
issymmetric
returns logical 0
(false
).
Data Types: single
| double
| logical
Complex Number Support: Yes
skewOption
— Test type
"nonskew"
(default) | "skew"
Test type, specified as "nonskew"
or "skew"
. Specify
"skew"
to test if A
is skew-symmetric.
More About
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
Since real matrices are unaffected by complex conjugation, a real matrix that is symmetric is also Hermitian. For example, the matrix
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
Since real matrices are unaffected by complex conjugation, a real matrix that is skew-symmetric is also skew-Hermitian. For example, the matrix
is both skew-symmetric and skew-Hermitian.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Code generation does not support sparse matrix inputs for this function.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Usage notes and limitations:
Code generation does not support sparse matrix inputs for this function.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
The issymmetric
function
fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray
(Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced in R2014a
See Also
ishermitian
| isreal
| transpose
| ctranspose
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)