Why does the polyval operator not work as expected. Is the ans variable not stored as a column vector? Why aren't the second, fifth, and sixth results equal?
>> roots([1,-8,17,2,-24])
ans =
4.0000 3.0000 2.0000 -1.0000
>> polyval([1.-8,17,2,-24],ans)
ans =
-192.0000 -54.0000 -8.0000 -2.0000
>> roots([1,-8,17,2,-24])
ans =
4.0000 3.0000 2.0000 -1.0000
>> x=ans
x =
4.0000 3.0000 2.0000 -1.0000
>> polyval([1,-8,17,2,-24],x)
ans =
1.0e-13 * 0.8882 0.3197 0.0355 0.1421
>> polyval([1,-8,17,2,-24],[2.0000;3.0000;-1.0000;3])
ans =
0 0 0 0
Best Answer