Constrain variables and results using nlinfit

5 ビュー (過去 30 日間)
Emilie
Emilie 2017 年 9 月 8 日
コメント済み: Pooja Lalan 2017 年 9 月 18 日
Hello,
Basically I am fitting a result vector Y to a matrix X of 4 variables. Whatever the values of X my results vector Y should only take values between 0 and 1. How can I translate this in Matlab so that the fitting knows it should aim this range?
Example:
X= [1 5 8 2; 2 3 6 2; 8 5 4 1; 6 3 1 7]; Y= [0.2; 0.3; 0.7; 0.5];
modelfun = @(F,X) F(1).*X(:,1) + F(2).*X(:,2) + F(3).*X(:,3) + F(4).*X(:,4) + F(5).*X(:,3).*X(:,4) + F(6);
F_fitted = nlinfit(X,Y,modelfun,[1 10 1 1 1 1]);
-------------------------------
Thanks for your time!
  1 件のコメント
Pooja Lalan
Pooja Lalan 2017 年 9 月 18 日
If I understand correctly, you would like the fitted parameters to result in a curve that takes values only between 0 and 1. Ideally you shouldn’t have to do that if you have good quality and quantity of data samples. The fitted curve should model the underlying ‘true’ curve. Constraining the output would not be mathematically sound. While there are ways of post-processing the fitted curve, like clipping the output at 0 and 1, there is no direct way of telling MATLAB to satisfy this constraint for all X while performing the curve fit.
Is there a particular reason why you would like to do that? Could you provide more information about your specific use case?

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

回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by