필터 지우기
필터 지우기

How to return the original polynomial from the calculated roots

조회 수: 1 (최근 30일)
Basim Touqan
Basim Touqan 2021년 4월 28일
답변: Dyuman Joshi 2021년 5월 1일
Hi MATLAB experts,
I have following example:
Solve the equation 3x^2-2x-4
Create a vector to represent the polynomial, then find the roots.
>> p=[3 -2 -4];
>> r=roots(p)
ans =
1.5352
-0.8685
I find the roots and wanted to return back the same polynomial coefficients i used the follwing code:
>> poly(r)
ans =
1.0000 -0.6667 -1.3333
But the coefficients are not the same as the original polynomial coefficients.
The question is how to get or return the original polynomial coefficients?
Thanks & regards,
Basim Touqan

답변 (1개)

Dyuman Joshi
Dyuman Joshi 2021년 5월 1일
So, the coefficients are not the same, but they are similar.
%[1 -0.6667 -1.3333] is equal to [3 -2 4]/3.
This is because, poly() calculates equation in the form of x^2+b*x+c (a=1) instead of the generalised form a*x^2+b*x+c (i.e. the function is written in such a way).
If you want your solution to be in the generalised form, what you can do is multiply the equation with the first member of original equation.
p=[3 -2 4];
r=roots(p);
q=p(1)*poly(r);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by