How can I make a contour plot?

6 visualizaciones (últimos 30 días)
Roneau
Roneau el 11 de Nov. de 2022
Editada: Roneau el 12 de Nov. de 2022
  4 comentarios
Walter Roberson
Walter Roberson el 12 de Nov. de 2022
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 el 12 de Nov. de 2022
Thank you. I think I understand now.

Iniciar sesión para comentar.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by