分享兴趣,传播快乐,增长见闻,留下美好!亲爱的您,这里是LearningYard学苑。
今天小编为大家带来MATLAB三维绘图(1),欢迎您的用心访问!本期推文时长大约3分钟,请您耐心阅读。
Share interest,spread happiness,increase knowledge,and leave beautiful. Dear,this is the Learing Yard Academy!
Today,the editor brings the MATLAB 3D drawing (1). Welcome to visit! This tweet usually takes about 3 minutes to read. Please read patiently.
前两期,小编和大家一起学习了MATLAB二维图绘制。这一期,我们一起来学习一下MATLAB三维图绘制吧~
In the first two issues,the editor and everyone learned MATLAB two-dimensional drawing together. In this issue,let's learn about 3D drawing in MATLAB~
三维饼图
三维饼图和二维饼图的绘制差距不大,只需要将pie(x)函数换成pie3(x)。
我们输入:
x = [1,3,5,7,2];
pie3(x)
会得到一个三维饼图。
There is not much difference between the drawing of 3D pie chart and 2D pie chart,you only need to replace the pie(x) function with pie3(x).
We enter:
x = [1,3,5,7,2];
pie3(x)
You will get a 3D pie chart.
在这个基础上,如果我们想要凸显占比比较多的39%那一部分,我们可以给它设置一个偏移量。
我们继续输入:
explode = [0,0,0,1,0];
figure
pie3(x,explode)
其中,explode中,0是表示对应位置的数据不偏移,1表示对应位置的数据偏移。偏移后的效果如下:
explode = [0,0,0,1,0];
figure
pie3(x,explode)
三维点或线图
三维点或线图使用的是plot3(X)函数。我们输入:
x = 0:0.01:10*pi;
y = sin(x);
z = cos(x);
2.符号函数画图 (1)ezplot(‘f(x)’,[a,b])表示在a<x
plot3(x,y,z)
会得到:
x = 0:0.01:10*pi;
y = sin(x);
z = cos(x);
plot3(x,y,z)
will get:
当间距设置较大时,线图也就变成了点图。我们还可以根据自己喜好设置自己喜欢的颜色和线型。
我们输入:
x = 0:0.1:10*pi;
y = sin(x);
z = cos(x);
plot3(x,y,z,&39;,&39;,&39;)
会得到:
1、第一步,打开matlab应用程序,然后输入以下代码,见下图,转到下面的步骤。2、第二步,执行完上面的操作之后,按“确定”,这是函数的图像,已绘制完毕,见下图,转到下面的步骤。3、第三步,执行完上面的操作之后,在。
When the spacing is set larger,the line graph becomes a dot graph. We can also set our favorite color and line type according to our own preferences.
1、首先打开计算机,在计算机内打开matlab,然后在matlab界面内输入a=1:1:30;这是我们的源数据。2、然后再在界面内输入输入命令plot(a)。3、然后就可以把图像在软件内展示出来。4、然后在界面内打开数据列表。5、选择左。
We enter:
x = 0:0.1:10*pi;
y = sin(x);
z = cos(x);
plot3(x,y,z,&39;,&39;,&39;)
will get:
小编在这里使用的是星型标记,蓝色。
The editor used here is the star mark,blue.
曲面图
曲面图的绘制使用到的是surf(X,Y,Z)函数。surf(X,Y,Z) 创建一个三维曲面图,它是一个具有实色边和实色面的三维曲面。该函数将矩阵 Z 中的值绘制为由 X 和 Y 定义的 x-y 平面中的网格上方的高度。曲面的颜色根据 Z 指定的高度而变化。
我们输入:
[X,Y] = meshgrid(1:5:10,1:20);
Z = sin(X) + cos(Y);
surf(X,Y,Z)
会得到:
The surface graph is drawn using the surf(X,Y,Z) function. surf(X,Y,Z) creates a 3D surface plot,which is a 3D surface with solid edges and solid faces. This function plots the values in matrix Z as heights above the grid in the x-y plane defined by X and Y. The color of the surface changes based on the height specified by Z.
We enter:
[X,Y] = meshgrid(1:5:10,1:20);
Z = sin(X) + cos(Y);
surf(X,Y,Z)
will get:
其他曲面/线图及代码展示如下:
[X,Y] = meshgrid(-5:.5:6);
Z = Y.*sin(X) - X.*cos(Y);
s = surf(X,Y,Z,&39;,0.7)
cplxdemo
axis([-1.5,1.5,-1.5,1.5,-1.5,1.5])
用MATLAB画图,应注意:对于自变量是向量形式存在,在进行相乘、相除和乘法运算时,必须采用点运算符,即“.*”,“./”,“.^”。对于本例,可以这样做。>>x=0:0.05:1; %取0-1的若干个数值,以等差数列形式生成。
axProjection3D(&39;)
xt = @(t) exp(-t/9).*sin(6*t);
yt = @(t) exp(-t/9).*cos(6*t);
zt = @(t) t;
fplot3(xt,yt,zt,[-9 9])
axProjection3D(&39;)
认识函数:
surf:绘制曲面图
surfc:绘制含有等高线的曲面图
mesh:绘制网格图
meshc:绘制含有等高线的网格图
meshz:绘制含有帷幕的网格图
fsurf:基于函数的曲面图
fmesh:基于函数的网格图
Know the function:
surf: draw a surface graph
surfc: draw a surface plot with contour lines
mesh: draw a mesh graph
meshc: draw a grid with contour lines
meshz: draw a mesh map with curtains
fsurf: function-based surface plot
fmesh: function-based mesh graph
END
今天的分享就到这里了,如果您对文章有独特的想法,欢迎给我们留言。让我们相约明天,祝您今天过得开心快乐!
That&39;s sharing. If you have a unique idea about the article,please leave us a message,and let us meet tomorrow. I wish you a happy day!
Learning Yard 学苑
文案|Rue
排版|Rue
审核|圈儿