MATLAB: Hi everyone, I want to find the polynomials from root. I want to get a value without decimal, how is that possible? Please find the example below for more clarification.

equationgcdgcd vectorpolynomialrootsvariables

Hi everyone,
I want to find the polynomials from root. I want to get a value without decimal, how is that possible? Please find the example below for more clarification.
>> poly([ -0.1667 + 1.2802i -0.1667 – 1.2802i])
ans =
1.0000 0.3334 1.6667
Which could be x^2+0.3334x+1.66667=0
But how do I obtain values without decimal? 3x^2+x+5=0 is same as x^2+0.3334x+1.66667=0
my question is how do i convert
ans =
1.0000 0.3334 1.6667
TO ===>
ans =
3 1 5

Best Answer

>> V = poly([ -0.1667 + 1.2802i -0.1667 - 1.2802i])
V =
1 0.3334 1.6667
>> [N,D] = rat(V,0.001) % get numerator and denominator
N =
1 1 5
D =
1 3 3
>> N = prod(D).*N./D % convert all to same denominator
N =
9 3 15
>> d=N(1); for k=N(2:end), d=gcd(d,k); end % find GCD
>> N = N./d % divide by GCD
N =
3 1 5