Borrar filtros
Borrar filtros

How can I show the contour plot of two functions in a graph?

4 visualizaciones (últimos 30 días)
JJLeov
JJLeov el 24 de Sept. de 2015
Comentada: T de Vries el 14 de Jun. de 2020
I have two contour plots below. I would like to show in the same graph both "contours.
How should I proceed?
Thanks.
x = linspace(-10,10);
y = linspace(-10,10);
[X,Y] = meshgrid(x,y);
Z = X.^2+Y.^2;
figure
contour(X,Y,Z, 'ShowText','on')
x = linspace(-10,10);
y = linspace(-10,10);
[X,Y] = meshgrid(x,y);
Z = X +Y;
figure
contour(X,Y,Z, 'ShowText','on')

Respuesta aceptada

Star Strider
Star Strider el 24 de Sept. de 2015
See if this does what you want:
x = linspace(-10,10);
y = linspace(-10,10);
[X,Y] = meshgrid(x,y);
Z = X.^2+Y.^2;
figure
contour(X,Y,Z, 'ShowText','on')
Z = X +Y;
hold on
contour(X,Y,Z, 'ShowText','on')
hold off
Use the hold function to make multiple plots on one set of axes.
  3 comentarios
T de Vries
T de Vries el 14 de Jun. de 2020
Dear Star Strider,
Hopefully, you or someone else, can help me.
I want to make a figure that plots two (and more) contourf plots in the same figure.
For this I used the hold on and hold off as mentioned above, but this is not working unfornutately. Can someone help me?
Kind regards,
Tessa

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by