How to fit a curve with forced initial value

21 次查看(过去 30 天)
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.

采纳的回答

Richard Willey
Richard Willey 2011-10-24
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])

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by