MATLAB: How to change the contour interval of a contour graph

3d plotscontourcontour levelsgraph

Hi, I am trying to plot a function using both mesh and contour plots. For the contour plot it asks that the contour lines have an interval of 0.1. How can I change the graph so it displays a contour line separation of 0.1?
x = linspace(-6,6,50); y = linspace(-10,10,50);
[X,Y] = meshgrid(x,y);
f = 2*exp(-X.^2-(1/4).*X.*Y-(1/8).*Y.^2);
figure
subplot(2,1,1);
mesh(X,Y,f);
subplot(2,1,2);
contour(f,'ShowText','on');

Best Answer

minx = round(min(f(:)),1);
maxx = round(max(f(:)),1);
levels = minx:0.1:maxx;
contour(f, levels, 'ShowText', 'on')