轮廓函数中的 "VN" 可选参数代表什么?

What does "VN" optional argument in contour function stand for?

它的文档很少(在 contourc 函数中):

VN is either a scalar denoting the number of lines to compute or a vector containing the values of the lines. If only one value is wanted, set 'VN = [val, val]'; If VN is omitted it defaults to 10.

我已经尝试了几个例子,它以某种方式影响了轮廓周围的线条数量。
它是否表示我的函数的斜率会有多平滑?
VN 代表什么?

说明

contourc 函数不会改变您的 data。它只是绘制它们。使用 VN 参数,您可以控制在您正在绘制的 topography/function 的最高点和最低点之间创建多少等高线。

如果将VN 设置为标量整数值,它直接指定行数。 VN=20 将在地形的最高点和最低点之间创建 20 个级别。

如果您指定一个值向量,您可以精确地控制在 data 中生成轮廓线的值。您应该注意这些值介于 min(data(:))max(data(:)) 之间。否则不会绘制线条。示例 VN=linspace(min(data(:)),max(data(:)),10) 将创建与未指定 VN 完全相同的等高线。

例子

为了说明VN参数的作用,我在这里举了一些例子。我使用 contour 函数直接绘制线条,而不是仅使用 contourc 计算它们,但效果是一样的。

% Create coordinate grid
[x,y]=meshgrid(-2:0.1:2,-2:0.1:2);
% define a contour function
z=x.^2 + 2*y.^3;
% create a figure
figure();
% plot contour
contour(x,y,z);
% make axis iso scaled
axis equal

示例 1

使用不带 VN 参数的轮廓命令产生以下结果

contour(x,y,z);

示例 2:VN=50

将 VN 设置为 50 轮廓(x、y、z、50);

示例 3:VN= 向量

此处使用将 VN 显式设置为等高线值向量以将等高线限制在相当窄的 z 数据范围内:

contour(x,y,z,linspace(-0.5,0.5,10));