Constrain variables and results using nlinfit
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Pooja Lalan
il 18 Set 2017
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?
Risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!