How to plot a set as the constraint in 2D?
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello All,
I want to find the optimal solution to an optimization problem in 2D by plotting the constrain set. The constraint sets are
and . I need to plot this area in 2D. I know that using meshgrid and surf does not do what I need. I tried the following piece of code after doing some searching on the similar questions.
syms x y
f(x, y) = sqrt(x^2+y^2 );
ezplot(f, [0, 10,0 10]
However, this method does not work as well. I would appreciate it if any one can help with this problem.
댓글 수: 0
채택된 답변
John D'Errico
2022년 4월 2일
편집: John D'Errico
2022년 4월 2일
Think clearly about what you are asking to plot.
sqrt(x1^2 + x2^2) < x1
Do you agree that x2^2 is ALWAYS a positive number, as long as x2 is real? In that case, is it true that x1^2 + x2^2 is ALWAYS strictly greater than x1^2, unless x2 is zero, in which case you just get x1^2?
Next, look at sqrt(x1^2 + x2^2). I just essentially proved that is is NEVER less than sqrt(x1^2). Do you understand that?
And what is sqrt(x1^2)? Yep. x1. well, unless you take the negative branch of the sqrt. But since you did not say that, then you have to recognize that
sqrt(x1^2+ x2^2) >= x1
But you are asking to plot the set of values for x1 and x2, that yield a result where EXACTLY the opposite happens. So the ONLY valid solution locus to your equations comes from the fairly limited set:
x2 == 0
x1 >= 0
That is, x2 MUST be EXACTLY zero.
Again, all of this applies IF you are taking the positive branch of the square root function. Since you never said differently, that is what I must assume.
But if you allow the negative branch of the square root, then ANY values of x and y will yield a valid solution, as long as x1>=0 and x2>-=0.
It is a pretty boring solution locus
참고 항목
카테고리
Help Center 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!