简体   繁体   English

在Matlab中绘制3D平面?

[英]Plot a 3D-plane in Matlab?

How can I plot a 3D-plane at specific point in Matlab? 如何在Matlab中的特定点绘制3D平面?

Consider the plane equation 考虑平面方程

Z=(-a * X - b * Y)/c

with following coefficients: 具有以下系数:

a=0.01; b=0.03; c= 1; d=0.

I want to plot this plane around point (100,100) not at origin (0,0). 我想围绕点(100,100)而不是原点(0,0)绘制此平面。 How it possible to do that? 如何做到这一点?

The code I used: 我使用的代码:

[X,Y] = meshgrid(x);
a=0.1;
b=0.2;
c=1;
d=0;
Z=(-a * X - b * Y)/c;
surf(X,Y,Z)
shading flat
xlabel('x')
ylabel('y')
zlabel('z')

surf() just plots whatever set of points you give it. surf()只是绘制您给出的任何点集。 To generate those points, you're evaluating the equation at a specific set of coordinates given by X and Y . 为了生成这些点,您需要在XY给定的一组特定坐标下评估方程。 Therefore you want those points to be centred around the region of interest: 因此,您希望这些点以感兴趣区域为中心:

[X, Y] = meshgrid(95:0.1:105);  % e.g. +/-5 at resolution of 0.1

or, say, for arbitrary view coordinates m , n : 或者,对于任意视图坐标mn

[X, Y] = meshgrid(m-20:m+20, n-20:n+20);  % e.g. +/-20 at resolution of 1

That gives you the view around 100,100 of a plane centred at the origin, which I think is what you're asking for. 这样一来,您可以围绕以原点为中心的100,100平面视图,我想这就是您要的。

Alternatively if you want the plane itself centred at 100,100, then you need that offset in the equation: 另外,如果您希望平面本身以100,100为中心,则需要在等式中指定该偏移量:

Z=(-a * (X - 100) - b * (Y - 100))/c;

so then a view centred on the origin will be equivalent to viewing the original plane around -100,-100. 因此,以原点为中心的视图将等同于查看-100,-100附近的原始平面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM