Why the results are different while using eig() to solve syms and double Jacobian matrix?
11 views (last 30 days)
Show older comments
Dearl all,
When I use eig to find the eigenvalues for a Jacobian matrix, the outputs are different if I define the Jacobian matrix as syms and double types. The order of each values are different in particular. I appreciate any clues for this difference:))
Many thanks,
JL
Here is an example:
% Create a syms J matrix and a dounble J matrix
JacobianSyms = vpa([1, 2, 3; 2, 1 8; 3, 8 9]);
JacobianDoub = double(JacobianSyms);
% Calculate their eigenvalues
[evs, eigenvaluesfromJacobianSyms] = eig(JacobianSyms)
[evd, eigenvaluesfromJacobianDoub] = eig(JacobianDoub)
0 Comments
Accepted Answer
Bruno Luong
on 27 Jul 2023
Edited: Bruno Luong
on 27 Jul 2023
If I ask a set of 3 integer numbers > 1 so that 30 is the product, what do you tell me?
(5,3,2) or
(5,2,3) or
(3,5,2) or
(3,2,5) or
(2,5,3) or
(2,3,5)
?
It's the same thing with eigen value and vectors, the order is just arbitrary set. So when you ask two different implementations for eigen values/vectors, you'll get the order that is arbitrary set by this routine.
7 Comments
Bruno Luong
on 28 Jul 2023
Edited: Bruno Luong
on 28 Jul 2023
BTW if you want to take the control and impose your order, for example sorted on real part of eigen value just do this
[V,D] =eig(A)
[~,p] = sort(real(diag(D)));
V = V(:,p)
D = D(p,p)
More Answers (0)
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!