# Solve my determinant equal to zero with roots

조회 수: 8 (최근 30일)
Daniel 2024년 2월 12일
댓글: Daniel 2024년 2월 14일
Hi!
I need help with solving for the roots of my polynomial im getting from my determinant of my matrices in a way where i dont have to collect the values manually in front of the variabel P from the determinant. Thanks in advance!
%%
clear all
clc
syms P
% Matrix definitions
KE_red =[13.0000 0 -8.4853;
0 13.0000 0;
-8.4853 0 8.0000];
KG_red =[ -(3*2^(1/2)*P)/65, 0, P/130;
0, -(3*2^(1/2)*P)/65, 0
P/130, 0, -(2*2^(1/2)*P)/195];
% Determinant
D=det(KE_red + KG_red)
% Solve for the roots of the determinant = 0
p = [-9*2^(1/2)/219700, 167/3380, -1328*2^(1/2)/195, 416];
r = roots(p)
[SL: formatted code as code. In the future please use the first button in the Code section of the toolstrip in the MATLAB Answers editor to create a section that formats code as code.]

댓글을 달려면 로그인하십시오.

### 채택된 답변

Steven Lord 2024년 2월 12일
You can use the vpasolve function to solve the polynomial, use the sym2poly function to automate extracting the vector of coefficients to a double precision vector, or use the coeffs function to automate extracting the vector of coefficients to a symbolic vector.
%%
syms P
sympref('FloatingPointOutput', false);
% Matrix definitions
KE_red =[13.0000 0 -8.4853;
0 13.0000 0;
-8.4853 0 8.0000];
KG_red =[ -(3*2^(1/2)*P)/65, 0, P/130;
0, -(3*2^(1/2)*P)/65, 0
P/130, 0, -(2*2^(1/2)*P)/195];
% Determinant
D=det(KE_red + KG_red)
D =
% Solve for the roots of the determinant = 0
p = [-9*2^(1/2)/219700, 167/3380, -1328*2^(1/2)/195, 416];
r = roots(p)
r = 3x1
592.8693 199.1684 60.8116
s = vpasolve(D)
s =
p2 = sym2poly(D)
p2 = 1x4
-0.0001 0.0494 -9.6311 415.9959
r2 = roots(p2)
r2 = 3x1
592.8696 199.1684 60.8110
p3 = coeffs(D, 'all') % Handle the case where one of the powers is not present
p3 =
r3 = roots(p3)
r3 =
To check, let's sort the various vectors. I'll use vpa to approximate the symbolic answers.
vpa([sort(r), sort(s), sort(r2), sort(r3)], 8)
ans =
Those look to be in pretty close agreement.
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Daniel 2024년 2월 14일
Thank you @Steven Lord

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

R2018b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by