MickG
MickG

Reputation: 3276

Converting array into polynomial

In MATLAB, there exists a function ppval for evaluation of polynomials in points, which given the polynomial in opportune format and the points where to evaluate it as input, returns the vector of the evaluations. Now I have built a function that finds the coefficients of a certain polynomial. Is there a function that, given an array of coefficients, converts it to the polynomial format ppval works with? Or do I have to build a function that evaluates the polynomial myself?

Upvotes: 0

Views: 1432

Answers (1)

Luis Mendo
Luis Mendo

Reputation: 112679

I think you want polyval:

Y = POLYVAL(P,X) returns the value of a polynomial P evaluated at X. P is a vector of length N+1 whose elements are the coefficients of the polynomial in descending powers.

    Y = P(1)*X^N + P(2)*X^(N-1) + ... + P(N)*X + P(N+1)

Note ppval is for evaluation piecewise-polynomial functions, rather than polynomials.

Upvotes: 1

Related Questions