【发布时间】:2014-11-13 17:12:16
【问题描述】:
我正在尝试为 z = 0 的 xy 平面中的自定义函数返回的 3D 矢量生成等高线图。
我试过了,但我得到一个空图:
% Stand in for the real function I want to plot.
f = @(x, y, z) [x ^ 2, y ^ 2, x * y + z];
x = linspace(-5, 5, 50);
y = linspace(-5, 5, 50);
z = zeros(length(x), length(y), 3);
% I know this can be vectorized but the function I really want to graph can't
% be.
for i = 1:length(x)
for j = 1:length(y)
z(i, j, :) = f(x(i), y(j), 0);
end
end
figure;
axis equal;
contour(x, y, z);
【问题讨论】: