MATLAB Problems

  • MATLAB
  • Thread starter ColdFusion85
  • Start date
  • #1
142
0
This is a MATLAB question. I am trying to find the eigenvalues of a matrix with both real and complex numbers. This is my session.

>> A=[1/sqrt(2),i/sqrt(2),0; -1/sqrt(2),i/sqrt(2),0; 0,0,1]

A =

0.7071, 0 + 0.7071i, 0
-0.7071, 0 + 0.7071i, 0
0, 0, 1.0000

>> eig(A)

ans =

0.9659 - 0.2588i
-0.2588 + 0.9659i
1.0000

However, matrix A is unitary, so [tex]|\lambda|[/tex] should equal 1. This is true for the third eigenvalue, but not for the other two. I even noticed that MATLAB fails to confirm A is unitary:

A =

0.7071, 0 + 0.7071i, 0
-0.7071, 0 + 0.7071i, 0
0, 0, 1.0000

>> B=[1/sqrt(2),-1/sqrt(2),0; i/sqrt(2),i/sqrt(2),0;0,0,1]

B =

0.7071, -0.7071, 0
0 + 0.7071i, 0 + 0.7071i, 0
0, 0, 1.0000

>> A*B

ans =

0, -1, 0
-1, 0, 0
0 , 0, 1

Why is MATLAB giving me incorrect answers? It was even doing this for me yesterday when I was dealing with real matricies. It was giving me eigenvalues with imaginary components when they were, in fact, all real. What's the deal?
 

Answers and Replies

  • #2
Wrichik Basu
Insights Author
Gold Member
2020 Award
1,624
1,512
However, matrix A is unitary, so |\lambda| should equal 1. This is true for the third eigenvalue, but not for the other two.
Have you checked using the abs function for each eigenvalue? I get 1 on checking for each eigenvalue.
I even noticed that MATLAB fails to confirm A is unitary
Are you trying to find the Hermitian conjugate of A and multiplying A with it to get I? Don't do it like that. Use ctranspose(A)*A. You'll surely get the identity matrix.
 

Related Threads on MATLAB Problems

  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
4
Views
5K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
5
Views
2K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
17
Views
3K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
3
Views
4K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
2
Views
2K
Top