Constrain variable and result range using linfit
Show older comments
Hello, Basically I am fitting a set of data containing 4 variables (matrix X) and result vector Y. When I perform the fitting using nonlinfit I would like to constrain my variables (so each column of X) to a specific range of values, and also my result vector Y. Moreover I would like to impose the fitting factors to be positive.
Example :
X =[ 150 1 5 5 ; 160 2 10 10 ; 170 3 15 15;140 1 10 15]; Y =[1;8;73;68];
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]);
I would like to constrain X(:,1) to [0:190], and Y(:) to [0:1]. Otherwise I obtain results which do not reflect my experimental reality.
Thanks!
Answers (0)
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!