KGV*_*KGV -1 matlab plot surface matlab-figure
我想获得 3D 曲面图。我的输出如下。
对于 z 的特定值,我为每个 x 值得到 y(x 的范围如0:0.1:1.4
)。
然后我改变 z,对于相同的 x 范围,我得到 y 值。
结果可以可视化为离散 z 值处的二维图,由 x 的范围及其相应的 y 组成。这是我原来的情节:
我想创建一个 3D 曲面图,就像一条毯子包裹在上面的 2D 图上。
这是两种类型的图的示例:
figure
hold on
grid on
view(30,40)
x = 0:.01:4;
z = .3:.3:3;
y = NaN(numel(x), numel(z));
for k = 1:numel(z)
y(:,k) = abs((4-x).*sin(x/(1+z(k)))); % compute a vector as function output
% for input vector x, for each z. Store as a column in matrix y
plot3(x,repmat(z(k),size(x)),y(:,k)) % plot in 3D space
end
figure
surf(x,z,y.','edgecolor','none') % surface plot
view(30,40)
grid on
Run Code Online (Sandbox Code Playgroud)