You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
% POLYFITC allows the user to provide the polynomial fitting
% procedure with constraints regarding the polynomial degree.
% Note, that this function does not provide the centering and scaling
% transformations option as the original polyfit function does.
%
% Usage:
% P = polyfitc(X, Y, N)
% where:
% X : a vector containing the x data
% Y : a vector containing the y data
% N : a vector containing the desired polynomial degrees (see examples)
% Note, that N can only contain unique positive integers
% P : a vector with the resulting coefficients
%
% P = polyfitc(X, Y, N, option)
% where option can be:
% 'raw' {default}: coefficients will be in the order as given in N
% 'asc' : coefficients will be returned in ascending order
% (lowest order first)
% 'desc' : coefficients will be returned in descending order
% (highest order first)
% 'polyval' : coefficients will be returned such that they can be
% used in the MATLAB polyval function
%
% Example:
% Suppose you know that the data you want to fit is purely quadratic in
% nature and may have an offset, but you are sure that there is no linear
% term present in the equation. The regular polyfit function will give you
% a linear term. POLYFITC offers the choice which orders to fit and return
% the result in a vector which can be used in polyval if desired:
%
% X = -9:9;
% Y = -sqrt(1i^1i)*X.^2 + 10; % dummy function
% X = X + rand(1,19) - 0.5; % add some noise to X
% Y = Y + 3*(rand(1,19)-.5); % add some noise to Y
% Pnormal = polyfit(X, Y, 2) % normal MATLAB polyfit result (linear term)
% Pmimic = polyfitc(X, Y, 0:2, 'desc') % mimic the MATLAB polyfit
% Ppolyval = polyfitc(X, Y, [0 2], 'polyval') % force linear term to zero.
%
% (C) M. van Dijk, FOCAL, 2014-09
Cite As
Marc (2026). Constraint polynomial fit (https://www.mathworks.com/matlabcentral/fileexchange/47851-constraint-polynomial-fit), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0.0 (3.31 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 |
