Fast Polynomial Curve and Surface Fitting

Version 1.0.3 (3.72 KB) by Moreno, M.
Fast polynomial curve and surface fitting via LLS. The functions are significantly faster than the default functions for ordinary problems


Updated 21 Jun 2022

View License

[k,r] = pcfit(x,y,n)
y = pcval(k,x)
[k,r] = psfit(x,y,z,n)
z = psval(k,x,y,n)
pcfit Polynomial curve fitting
pcval Polynomial curve evaluation
psfit Polynomial surface fitting
psval Polynomial surface evaluation
k process coefficients
r residuals
x x-coordinate
y y-coordinate
z z-coordinate
n process order
Fast polynomial process fitting and evaluation via linear least squares (LLS). Significant speed increases over the MATLAB's functions for low and medium sized problems at the cost of numerical stability and robustness. The direct resolution of the linear system with iteratively-assembled Vandermonde matrices is the key advantage of the code, as well as the surface evaluation assuming the coefficients form an upper-triangular matrix.

Cite As

Moreno, M. (2023). Fast Polynomial Curve and Surface Fitting (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

Faster residual check without pcval or psval at the cost of no Vandermonde matrix destruction. Replacement of nested linear indices to avoid declaring new variables via destruction.


Optimisation of the surface fitting algorithm and correction of the function description text.


Commented demo codes and addition of the calculation of the absolute fitting error. Faster surface coefficient matrix's non-zero element count via triangular numbers.