Hi,

I have to evaluate a piecewise polynomial (PP) in the cost function of the solver, but I’m not sure how I can include that in the CasADi expression. The piecewise polynomial is the result of Matlab’s spline(…) function for a large amount of data. So in pure Matlab one would use ppval(…) for the evaluation at a certain value “x”. In my case “x” is a SX.sym from CasADi. Does anybody know how I could do that?

I’ve already tried to manually do the calculation (find the right interval with a for-loop, then compute the polynomial with the corresponding coefficients). But it seems like if-statements and for-loops don’t work with CasADi.

BR

Martin