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 CenterFile Exchange에서 Get 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