fitted curve start from zero?

11 ビュー (過去 30 日間)
Davide Cerra
Davide Cerra 2018 年 12 月 9 日
コメント済み: Star Strider 2018 年 12 月 9 日
How can the fitting curve can stat from [0,0]?
Untitled.png

回答 (1 件)

Star Strider
Star Strider 2018 年 12 月 9 日
The easiest way is to not specify a y-intercept in the model you want to fit.
Example —
x = 0:2:100;
y = 3E+3 - (x-50).^2 + (x-50) + randn(1, numel(x))*50;
B = [x(:).^2 x(:)] \ y(:);
Y = [x(:).^2 x(:)] * B;
figure
plot(x, y, '.', x, Y, '-r')
grid
Here, x begins at 0, and not including a y-intercept in the model is the same as forcing it through 0.
Experiment to get the result you want, with your model and data.
  2 件のコメント
Davide Cerra
Davide Cerra 2018 年 12 月 9 日
thank you,
is thera an easy way to impose constraints in the curve fitting toolbox?
Star Strider
Star Strider 2018 年 12 月 9 日
My pleasure.
You can impose some constraints with lsqcurvefit and the other Optimization Toolbox functions. This depends on what you want to constrain.
I don’t have the Curve Fitting Toolbox. (I can do everything I need with the Optimization and Statistics and Machine Learning Toolboxes.)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by