Fit polynomial p to data, but match exactly at one or more points
Updated 20 Jan 2020

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Sometimes we want to fit a polynomial to some data, but want to force a perfect match to some known values at one or more points. This function returns such a polynomial.

Cite As

Are Mjaavatten (2024). polyfix(x,y,n,xfix,yfix,xder,dydx) (https://www.mathworks.com/matlabcentral/fileexchange/54207-polyfix-x-y-n-xfix-yfix-xder-dydx), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Polynomials in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

Changed image

Added image

Fixed the error in version pointed out by Jacob Bresler.

As requested by Jacob Bresler, I have added optional outputs S and mu, to make the output from polyfix conform with polyfit

Fixed trivial errors in the help section

Version 1.1 includes an option for specifying derivatives. p is now a row vector, for consistency with polyfit