I want to track specific eigenvalues belonging to some matrix using Matlab. Say we have a matrix A = A(x) and I want to see what happens to specific eigenvalues of A as I move x in a loop.
The problem is that when using the Matlab eig function it seems that the eigenvalues are not 'consistently' placed in the output vector. I've created an example of the problem
clc
clear all
close all
xMin = 0;
xMax = 100;
Nx = 1001; % changed from 101 to 1001 to highlight 'continuous' eigenvalues
xRange = linspace(xMin, xMax, Nx);
for ix=1:Nx
x = xRange(ix) + 1i;
A = [ cos(x)-sin(-x), 1; 1 cos(x)-exp(-x) ];
e = eig(A);
% e = e(1); uncomment this
figure(1);
hold on
grid on
scatter(real(e), imag(e));
end
If you run this code you will see a plot featuring two distinct eigenvalues. Now if you uncomment the commented line above so as to focus on and plot a specific eigenvalue you will see that the focus 'jumps' from one eigenvalue to the other at some point. So how can you focus on and plot just a single eigenvalue?