[英]How to use Matlab to draw these 3D shapes?
I am trying to use Matlab to create these 3D shapes for illustration purpose (Please see the image below). 我正在尝试使用Matlab创建这些3D形状以用于说明目的(请参见下图)。 I think surf is the function I should use;
我认为冲浪是我应该使用的功能; however, haven't got a clue what are the functions I should use to represent these shapes.
但是,我不知道我应该使用什么功能来表示这些形状。 Anyone can suggest an example please?
任何人都可以提出一个例子吗? Thanks.
谢谢。
A. 一种。
Edit 1: 编辑1:
Thanks for the replies from Trogdor and PetrH. 感谢Trogdor和PetrH的回复。
Currently, I am trying to plot a shape that is more sharp. 目前,我正在尝试绘制更清晰的形状。 For example, z = x.^2 + y.^2;
例如,z = x。^ 2 + y。^ 2; can plot a normal cup shape.
可以绘制正常的杯子形状。 However, I want to plot something like the subplot on the right hand side shown below.
但是,我想在右侧显示子图,如下所示。 Tried several different function but not working.
尝试了几种不同的功能,但无法正常工作。 Thanks for any tips!
感谢您的提示!
Edit 2: 编辑2:
Use z = x.^2 -4*x+ y.^2-4*y; 使用z = x。^ 2 -4 * x + y。^ 2-4 * y; can make the shape more flat.
可以使形状更平坦。 Still haven't got a method to make it sharp.
仍然没有办法使它变得清晰。
You can use meshgrid to generate x and y matrices to plug into az function. 您可以使用meshgrid生成x和y矩阵以插入z函数。 For example:
例如:
[x,y] = meshgrid(-10:10);
z = x.^2 + y.^2;
figure;surf(z);
will generate a plot similar to the first figure. 将生成类似于第一个图的图。 The second figure is the same thing, but defining z as:
第二个图是相同的东西,但是将z定义为:
z = y.^2;
And so on. 等等。
EDIT: The third figure is a saddle, found using 编辑:第三个数字是鞍,使用
z = x.^2 - y.^2;
Thanks to PetrH for pointing that out. 感谢PetrH指出这一点。
The 4th and fifth are inversions of the first two. 第四个和第五个是前两个的反转。
z = -x.^2;
z = -x.^2 - y.^2;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.