Reputation: 25
I have two K
-by-K
matrices, A
and B
, B
is diagonal. I want to find roots of the equation :
det(Ax+B) = 0
In MATLAB
. x
is multiplied element by element with A
. I know that det(Ax+B)
is a K-order polynomial of x
.
How can I find the coefficients of this polynomial? If I find these coefficients, I can find the roots of the above equation by roots()
in MATLAB. If not, I should use fzero
.
Best M. R.
Upvotes: 2
Views: 69
Reputation: 112689
You can use the Symbolic Toolbox. The following illustrates how to do it:
>> A = magic(4) %// example matrix
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
>> B = diag([4 2 6 5]) %// example matrix
B =
4 0 0 0
0 2 0 0
0 0 6 0
0 0 0 5
>> syms x
>> det(A*x+B)
ans =
- 11016*x^3 + 1342*x^2 + 2568*x + 240
Upvotes: 2