Friday, October 30, 2009

Matlab polynomial basics: roots, derivative of polynomial, evaluate polynomial



%Get roots of function

octave-3.2.3:13> A = [1 -3 3 -1]
A =

1 -3 3 -1

octave-3.2.3:14> roots(A)
ans =

1.00001 + 0.00000i
1.00000 + 0.00001i
1.00000 - 0.00001i

%get derivative of polynomial

octave-3.2.3:18> A
A =

1 -2 1

octave-3.2.3:19> polyder(A)
ans =

2 -2


%evaluate polynomial using matrix notation

polyval(A,1)
ans = 0
octave-3.2.3:21> polyval(A,2)
ans = 1

No comments:

Post a Comment