MATLAB: How to solve the eigen problem with the matrix have same eigenvalue

eigen problemeigenvector

Dear all,
I am now working on slove the eigen problem of a matrix(4*4). What is known to me is that the matrix have two same eigenvalue, and it seems that Matlab cannot solve the eigenvector properly. Does anyone meet the same problem? Or can anyone help me to improve the calculation efficiency of my code? Here is the code in the attachment~~~
Many thanks in advance~~~
HX

Best Answer

Computing the eigenvalues and eigenvectors of a general numeric 4-by-4 matrix is fairly easy.
Computing the eigenvalues and eigenvectors of a general symbolic 4-by-4 matrix is not.
A = sym('A', [2, 2]);
tic; [V, D] = eig(A); toc
length(char(V))
On my machine this took about 0.13 second and returned a V array with 202 characters.
A = sym('A', [3, 3]);
tic; [V, D] = eig(A); toc
length(char(V))
This took only about 0.2 seconds, but V was over 30,000 characters long. Note that the elements of A are each 4 characters long.
When I used a 4-by-4 A, it took 215 seconds and the resulting V was over six and a half million characters long. For comparison, computing the eigenvalues and eigenvectors of a rand(4, 4) matrix took about 0.02 seconds.
Above 4-by-4 you're probably going to run into Abel-Ruffini if you try to compute eigenvalues and eigenvectors of general symbolic matrices.
I recommend substituting numeric values for as many of your symbolic variables as you can in your symbolic matrix before trying to compute the eigenvalues and eigenvectors. [I suspect you're going to object that you want to solve the problem generically then substitute values for kx and ky in later; it will be MUCH quicker if you substitute values in first and THEN compute the eigenvalues and eigenvectors. See: 215 seconds for symbolic versus 0.02 seconds for numeric.]