How to make a polyfit with constraints to the first and second derivative?

17 views (last 30 days)
I want to make a polyfit of some data. The start and end point, and also the derivative and second derivative in begin and endpoint are knowns, how do I make a polyfit, which fulfills to this needs?
I found a polyfix, function, where you can give constraints to the start and end point, and also the derivative, but you cannot add a constraint to the second derivative. Is there another solution?
This is the link to the polyfix function: https://nl.mathworks.com/matlabcentral/fileexchange/54207-polyfix-x-y-n-xfix-yfix-xder-dydx

Accepted Answer

Matt J
Matt J on 9 May 2023
More often than not, if you have such constraints, it is spline that you want to fit, not a polynomial. Constrained spline fits can be done with this FEX download:
  2 Comments
Toon Van Dyck
Toon Van Dyck on 9 May 2023
I already tried the slm function. I need a polynomial function of at least degree 5, and this function can only fit functions of degrees 1,2 and 4.
Matt J
Matt J on 9 May 2023
Yes, but they are splines. An order 4 spline is much more flexible than a degree five polynomial.

Sign in to comment.

More Answers (1)

Matt J
Matt J on 9 May 2023
Well they are just linear constraints on the coefficients, so you could use lsqlin if you have the Optimization Toolbox.

Categories

Find more on Polynomials in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!