[英]A 3D plot in MATLAB
I have two variables which i sweep, W1
and W3
. 我扫描了两个变量
W1
和W3
。 I made a nested loop of these two variables. 我对这两个变量进行了嵌套循环。
for i=1:size(W1,2)
for j=1:size(W3,2)
d(i,j)=someexpression(W1(i),W3(j))
end
end
I want to do a 3D plot with W1
in the x-axis and W3
in the y-axis and d should be in the z-axis so that I have a 3D plot (or some contour plot). 我想用x轴上的
W1
和y轴上的W3
来做一个3D绘图,而d应该在z轴上,这样我就有了一个3D绘图(或某些轮廓绘图)。
EDIT: The 3d plot should actually be a surface 编辑:3d图实际上应该是一个表面
You can do the interpolation manually: 您可以手动进行插值:
x = linspace(W1(1), W1(end), 100);
y = linspace(W2(1), W2(end), 100);
z = interp2(W1, W2, d, x, y);
surf(x, y, z)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.