polycost

polycost(gencost, Pg, der)

polycost() - Evaluates polynomial generator cost & derivatives.

F = POLYCOST(GENCOST, PG) returns the vector of costs evaluated at PG

DF = POLYCOST(GENCOST, PG, 1) returns the vector of first derivatives
of costs evaluated at PG

D2F = POLYCOST(GENCOST, PG, 2) returns the vector of second derivatives
of costs evaluated at PG

GENCOST must contain only polynomial costs
PG is in MW, not p.u. (works for QG too)

This is a more effecient implementation that what can be done with
MATLAB's built-in POLYVAL and POLYDER functions.