Effacer les filtres
Effacer les filtres

Fitting a function to data (fminsearch) with limits

105 vues (au cours des 30 derniers jours)
loes visser
loes visser le 30 Août 2016
Hey!
I try to fit a model to measured data. I already got a real close with the fminsearch option. However, I know the model will never fit completly to the measured data. I know the range wherein the unknown factors should be, how can I include this in the function.
This is a part of my code;
p= [0.31;114;3.5];
y2=fitfunc(TempZone1day,TempZone2day,TempZone3day,TempZone4day,TempZone5day,buitenTempday,FlowZone1day,FlowZone2day,FlowZone3day,FlowZone4day,KNMIwindday,SMA,p);
figure(1)
plot(tijd,WarmteCvday,'+',tijd,y2,'-')
a0=p;
aBest = fminsearch(@(a) SumErrfun1(a,TempZone1day,TempZone2day,TempZone3day,TempZone4day,TempZone5day,buitenTempday,FlowZone1day,FlowZone2day,FlowZone3day,FlowZone4day,KNMIwindday,SMA,WarmteCvday,tijd),a0);
disp(aBest)
For example, I know that p(1) should be within 0.1-0.5, p(2) within 100-200 and p(3) within 2-6. Because now aBest (the best combination) is [-0.0328; 61.8202; 0.4375], which is not even a possible option. How can I include these ranges?

Réponse acceptée

John D'Errico
John D'Errico le 30 Août 2016
Modifié(e) : John D'Errico le 30 Août 2016
fminsearch has no capability to take bounds on the search. If the objective is such that a better result lies outside of where you want it, too bad. :)
Having said that, you can use fminsearchbnd , a tool found on the file exchange. It does allow bounds on the variables. Just download and install that tool on your search path, then use it instead.
  1 commentaire
loes visser
loes visser le 30 Août 2016
Super, thanks! It's working :)

Connectez-vous pour commenter.

Plus de réponses (3)

Jie Jian
Jie Jian le 9 Jan 2020
Or you can use the function 'mapping_parameters.m' to transfer unbounded parameters to bounded ones

kursat cihan
kursat cihan le 30 Août 2020
John D'Errico....much love from Germany, helped me a lot!!!
Bachelor Thesis in Material Modelling, used it for a parameter optimization in bringing simulations together with experimental data...PEACE
  1 commentaire
Delme
Delme le 18 Jan 2021
Haha, i'm doing exactly the same in my thesis!

Connectez-vous pour commenter.


Stefan Schuberth
Stefan Schuberth le 8 Nov 2022
you can use q=f1*atan(p)+f2 to construct a limited parameter q from an unlimited parameter p :)

Catégories

En savoir plus sur Get Started with Optimization Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by