如何在 Matlab 中绘制特定的等高线

How to plot a specific contour line in Matlab

考虑这个例子:

X = 0:0.01:1;
Y = 0:0.01:1;
[x,y] = meshgrid(X,Y);
z = sin(x.*y);
contourf(x,y,z,'ShowText','on')

等高线的值是自动确定的。如何绘制具有 [0.1,0.3,0.44,0.63,0.78,0.89] 等特定值的特定等高线?

如果所需的值为

  v = [0.1,0.3,0.44,0.63,0.78,0.89]

然后我们有

X = 0:0.01:1;
Y = 0:0.01:1;
[x,y] = meshgrid(X,Y);
z = sin(x.*y);
contourf(x,y,z,[0.1,0.3,0.44,0.63,0.78,0.89],'ShowText','on')

矢量 'v' 的位置必须在 'z' 之后。