how to pass a constrain in lsqcurvefit?

2 ビュー (過去 30 日間)
Arun Kumar Bar
Arun Kumar Bar 2018 年 12 月 29 日
コメント済み: Arun Kumar Bar 2019 年 1 月 1 日
Hi;
For a data set (x, y), I am trying to fit a function , fun(m, x), where there are four independent parameters m1, m2, m3 and m4, with the condtion that m1>m2. Could anyone please suggest how could I pass this condition in the following?
x=xdata;
y=ydata;
fun=(m,x);
lb=[];
m0=[m01; m02; m03]
ub=[];
m=lsqcurvefit(fun, m0, xdata, ydata, lb, ub);
Thank you very much in advance!
Kind regards,
Arun

採用された回答

John D'Errico
John D'Errico 2018 年 12 月 29 日
You cannot impose a strict inequality constraint. In fact, as you have learned based on your other question, sometimes even the bounds can be exceeded by a small amount.
There are simple ways to fix this, for example, using a transformation. Thus you might do something like this in your objective function:
function z = fun(m,x)
mt = m;
mt(2) = m(1) + exp(m(2));
...
Now there are no questions about an inequality. You will need to supply intelligent starting values for the initial m. And when lsqcurvefit returns a result, you must transform it the same way to have the parameters in your desired form. Or, you might use a transformation like
mt(2) = m(1) + m(2)^2;
Alternatively, you can use tools like fmincon to impose an inequality constraint. But remember that fmincon also does not understand a STRICT inequality of the form m(1)>m(2), and it too can exhibit constraint violations on the order of TolCon.
  1 件のコメント
Arun Kumar Bar
Arun Kumar Bar 2019 年 1 月 1 日
Thanks John!
Regards,
Arun

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by