How can I make a contour plot?

조회 수: 5 (최근 30일)
Roneau
Roneau 2022년 11월 11일
편집: Roneau 2022년 11월 12일
  댓글 수: 4
Walter Roberson
Walter Roberson 2022년 11월 12일
Well you can certainly create a grid and contour() it. And you can plot(xopt(1), xopt(2), '*') to mark the location of the minima on the contour plot.
Drawing the boundaries of the nonlinear constraints could be more difficult, depending on what they are. You could, though, evaluate the nonlcon function at each grid location and figure out from the output whether each point is inside the boundary or not, and draw something appropriate on the contour plot.
Roneau
Roneau 2022년 11월 12일
Thank you. I think I understand now.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2022년 11월 11일
[x, y] = meshgrid(-5:5, -5:5);
z = x.^2 + 10.*y.^2 - 3.*x.*y;
contour(x, y, z)
  댓글 수: 2
Roneau
Roneau 2022년 11월 11일
Thank you for this!
Matt J
Matt J 2022년 11월 12일
@Roneau, you should Accept-click the answer if it addresses your question.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by