add contraints on parameters defined in function
이전 댓글 표시
I have a function:
y =x.^a + z.^b
For which I wrote a separate function as I neet to fit it over my data. But I want to add constraint: a>b. How will I do that? Please help me with it. Thanks
댓글 수: 5
Walter Roberson
2018년 1월 19일
What do you want to have happen if the caller attempts to violate the constraints?
John D'Errico
2018년 1월 19일
편집: John D'Errico
2018년 1월 19일
It is meaningless to say you have a constraint on a and b, because the function does not constrain them. A function is just a function. It does not care what you give it.
You want to use a fitting tool to fit some data, but you do not tell us which tool that is. That is the tool which must understand that the parameters are constrained, NOT the function to be fit.
So you need to use a tool that can handle inequality constraints on the parameters. And as it turns out, few such tools do allow general linear inequality constraints. But you could formulate the problem to be fit using fmincon.
Or, you could redefine the model to be in the form
y = x.^(a+b) + z.^b
where a was specified to have a lower bound of 0. Many tools allow bound constraints on the parameters.
Giru Mishra
2018년 1월 19일
Torsten
2018년 1월 19일
Use "lsqcurvefit" together with the model function y=Const*(x^(c1+c2)+z^c1) and include the bound constraint c2>0.
Once lsqcurvefit has determined c1 and c2, a=c1+c2 and b=c1 in your original model.
Best wishes
Torsten.
Giru Mishra
2018년 1월 19일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File 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!