Maximizing using fminsearch over an interval
이전 댓글 표시
I want to maximize
(((cos(p(1))*sin(p(2)))-(f1*(cos(p(1))*sin(p(2)))+f2*(sin(p(1))*sin(p(2)))+f3*cos(p(2)))*d1)^4+((sin(p(1))*sin(p(2)))-(f1*cos(p(1))*sin(p(2))+f2*sin(p(1))*sin(p(2))+f3*cos(p(2)))*d2)^4+((cos(p(2)))-(f1*cos(p(1))*sin(p(2))+f2*sin(p(1))*sin(p(2))+f3*cos(p(2)))*d3)^4)^(1/4);
for p(1) from -pi..pi and p(2) from -2pi..2pi
Is there a way to restrict the input to an interval?
TIA
답변 (2개)
Walter Roberson
2013년 10월 21일
0 개 추천
No. If you have an interval use fminbnd() or related if you have the Optimization toolbox; if you do not have that toolbox then use fzero() on the derivative of the function if it is a function of one variable.
If you do not have the optimization toolbox and it is a function of more than one variable, you might be able to get somewhere using the Symbolic Mathematics Toolbox.
It appears to me that there are multiple identical maxima in the range you specify. Depending on the parameters I use, I find 8, or 12, or maybe an infinite number (I'm still processing that case to see if there is a subtle wave that I do not see visually.)
Alan Weiss
2013년 10월 21일
편집: Alan Weiss
2013년 10월 21일
0 개 추천
If you use the optimization decision table for your nonlinear problem with bound constraints, you see that you should use fmincon as your solver. It is easy to set a range for fmincon, just give lower and upper bounds.
Alan Weiss
MATLAB mathematical toolbox documentation
카테고리
도움말 센터 및 File Exchange에서 Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!