Azzera filtri
Azzera filtri

How to fit a curve with forced initial value

21 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Richard Willey
Richard Willey il 24 Ott 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])

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by