Effacer les filtres
Effacer les filtres

How to fit a curve with forced initial value

21 vues (au cours des 30 derniers jours)
Philippe
Philippe le 24 Oct 2011
Dear everybody,
I'm trying to fit a serie of datapoints with a function f(x) (e.g. a polynomial function)by forcing the value of the function at x=0. I tried to find the solution using "fit" and "polyfit" Matlab functions but the interpolating algorithm doesn't seem to take into account the initial value that I want. Could you help me ? Thanks by advance.

Réponse acceptée

Richard Willey
Richard Willey le 24 Oct 2011
Hi Phillippe
If you have Statistics Toolbox or Curve Fitting Toolbox its relatively easy to force this type of constraint.
Here's a simple example using Curve Fitting Toolbox where I constrain the intercept to take the value "4" by setting the upper and lower bound for the regression coefficient to be 4.
X = 1:100
X = X'
Y = 3* X + 5 + randn(100,1)
foo = fit(X, Y, 'poly1', 'Lower', [-Inf 4], 'Upper', [Inf 4])

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by