Unit-9
Polynomials
>> %Coefficients of a polynomial (For Eg., x2+5x+6=0)
>> a=[1 5 6];
>> roots(a)
ans =
-3.0000
-2.0000
>> %To find the coefficients of a polynomial from the given roots
>> b=[-3 -2];
>> poly(b)
ans =
1 5 6
>> %To evaluate the polynomial (Eg. Quadratic equation 3x2+2x+6 = 0 ) for a given value of x
>> p=[3 2 6];
>> polyval(p,2)
ans =
22
>> %To evaluate the polynomial (Eg. Quadratic equation 3x2+2x+6 = 0 ) for a given values of x
>> polyval(p,[1 3])
ans =
11 39
Be the first to comment