MATLAB: How to show the contour plot of two functions in a graph

combinecontour

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')

Best Answer

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.