百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术资源 > 正文

喆学(20):Matlab学习之三维曲面图

moboyou 2025-04-22 00:47 69 浏览


分享兴趣,传播快乐,

增长见闻,留下美好。

亲爱的您,这里是LearningYard学苑!

今天小编为大家带来文章

“喆学(20):Matlab学习之三维曲面图”

欢迎您的访问。

Share interest, spread happiness,

increase knowledge,and leave beautiful.

Dear, this is LearningYard Academy!

Today, the editor brings you the article

“Zhe Xue (20):

Matlab learning of three-dimensional surface map”

Welcome to visit!

一、思维导图(Mind Map)

二、平面网格数据的生成(Generation of Plane Grid Data)

在MATLAB中,平面网格数据通常指的是二维空间内定义的规则或不规则点集,这些点集能够表示平面上的几何形状、物理场的z轴分布、以及数据分布等。

In MATLAB, plane grid data usually refers to regular or irregular point sets defined in two-dimensional space. These point sets can represent geometric shapes on the plane, z-axis distribution of physical fields, and data distribution, etc.

(1)坐标矩阵(Coordinate Matrix)

在MATLAB中,平面网格数据常常通过坐标矩阵的形式来表示。具体地,矩阵的每一行都代表一个网格点的坐标。例如,矩阵X = [1, 2, 3; 4, 5, 6; 7, 8, 9]就展示了一个3x3的网格布局,意味着存在三个点,且每个点均包含三个坐标值。

In MATLAB, plane grid data is often represented in the form of a coordinate matrix. Specifically, each row of the matrix represents the coordinates of a grid point. For example, the matrix X = [1, 2, 3; 4, 5, 6; 7, 8, 9] shows a 3x3 grid layout, which means there are three points, and each point contains three coordinate values.

(2)网格生成(Mesh Generation)

1. meshgrid函数(meshgrid function)

meshgrid函数是生成二维网格的得力工具,它为二维空间数据的可视化和处理奠定了基础。当你需要在二维空间中绘制图形,例如作为三维曲面图的底面,或者进行二维插值任务时,meshgrid显得尤为实用。其基本语法为[X, Y] = meshgrid(x, y),其中x和y是两个向量,分别代表X轴和Y轴上的点。该函数会返回两个矩阵X和Y:X的每一行都是x的副本,而Y的每一列都是y的副本。如此,X和Y便共同构成了一个网格,这个网格能够方便地应用于plot、mesh、surf等绘图函数中。

The meshgrid function is a powerful tool for generating two-dimensional grids, which lays the foundation for the visualization and processing of two-dimensional spatial data. Meshgrid is particularly useful when you need to draw graphics in two-dimensional space, such as as the bottom surface of a three-dimensional surface plot, or perform two-dimensional interpolation tasks. Its basic syntax is [X, Y] = meshgrid(x, y), where x and y are two vectors representing points on the X-axis and Y-axis respectively. The function returns two matrices X and Y: each row of X is a copy of x, and each column of Y is a copy of y. In this way, X and Y together form a grid, which can be easily applied to drawing functions such as plot, mesh, and surf.

2. linspace函数(linspace function)

MATLAB中的linspace函数能够在指定的区间内生成具有线性间隔的向量,它非常适合创建等间距的数值序列,并广泛应用于绘图、数值分析、算法实现等多种场合。具体使用语法为y = linspace(start, stop, num)。

The linspace function in MATLAB can generate vectors with linear intervals within a specified interval. It is very suitable for creating equally spaced numerical sequences and is widely used in various occasions such as drawing, numerical analysis, and algorithm implementation. The specific syntax is y = linspace(start, stop, num).

3. ndgrid函数(ndgrid function)

在MATLAB中,ndgrid函数用于生成多维网格,这在进行多维插值、数值积分或任何需要多维网格数据的操作时非常有用。ndgrid可以生成一个或多个维度的网格,并且可以很容易地与linspace或colon操作符结合使用。[X1, X2, ..., Xn] = ndgrid(x1, x2, ..., xn),例如,

In MATLAB, the ndgrid function is used to generate multidimensional grids, which is very useful when doing multidimensional interpolation, numerical integration, or any operation that requires multidimensional grid data. ndgrid can generate grids of one or more dimensions and can be easily combined with linspace or colon operators. [X1, X2, ..., Xn] = ndgrid(x1, x2, ..., xn), For example,

这将生成三个三维矩阵X、Y和Z,它们可以用于三维空间中的网格绘制或数值计算。

This will generate three three-dimensional matrices X, Y, and Z, which can be used for grid drawing or numerical calculations in three-dimensional space.

三、相关函数(Related functions)

(1) mesh函数和surf函数(mesh function and surf function)

mesh(x, y, z, c)为三维网格图,surf(x, y, z, c)为三维曲面图。一般 x,y, z 一般为同型矩阵,其中,x、y是网格坐标矩阵,z是网格点上的高度矩阵,c 用于指定在不同高度下的曲面颜色。c 省略时,颜色的设定正比于图形的高度。

mesh(x, y, z, c) is a 3D mesh graph, surf(x, y, z, c) is a 3D surface graph. Generally, x, y, and z are matrices of the same type, where x and y are grid coordinate matrices, z is the height matrix at the grid points, and c is used to specify the surface color at different heights. When c is omitted, the color setting is proportional to the height of the graph.

mesh(z, c)和surf(z, c)为mesh函数和surf函数的其他调用格式。当x、y省略时,z矩阵的第2维下标当作x轴坐标,z矩阵的第1维下标当作y轴坐标。

mesh(z, c) and surf(z, c) are other calling formats of mesh and surf functions. When x and y are omitted, the second dimension subscript of z matrix is regarded as the x-axis coordinate, and the first dimension subscript of z matrix is regarded as the y-axis coordinate.

(2)meshc, meshz, surfc, surfl函数(meshc, meshz, surfc, surfl functions)

meshc函数用于绘制三维网格线图,并在网格的轮廓上添加颜色编码的等高线。meshz函数用于在mesh函数绘制的网格图上,用不同颜色的网格线表示不同高度的Z值。surfc函数用于在三维曲面图上添加等高线。surfl函数用于在三维曲面图上添加等高线,并使用线条来连接等高线上的点。接下来我们通过一个列子来看看他们具体的区别。

The meshc function is used to draw a 3D mesh line graph and add color-coded contour lines to the outline of the mesh. The meshz function is used to use different colors of mesh lines to represent the Z values of different heights on the mesh graph drawn by the mesh function. The surfc function is used to add contour lines to a 3D surface graph. The surfl function is used to add contour lines to a 3D surface graph and use lines to connect the points on the contour lines. Next, let's take a look at their specific differences through an example.

(3) sphere函数和cylinder函数(sphere function and cylinder function)

sphere函数用于绘制球体。它可以生成球体的表面网格,并允许用户指定球体的半径和分辨率。常见的代码为[Theta, Phi] = sphere(n);surf(Theta, Phi, r);其中,n为一个正整数,表示生成的网格的精细度。n越大,网格越精细。Theta和Phi分别代表球体的经纬度坐标。r为球体的半径,默认为1。

The sphere function is used to draw a sphere. It can generate a surface mesh of a sphere and allow the user to specify the radius and resolution of the sphere. The common code is [Theta, Phi] = sphere(n);surf(Theta, Phi, r); where n is a positive integer, indicating the fineness of the generated mesh. The larger n is, the finer the mesh is. Theta and Phi represent the latitude and longitude coordinates of the sphere, respectively. r is the radius of the sphere, which defaults to 1.

cylinder函数用于绘制圆柱体。它生成圆柱体的表面网格,允许用户指定圆柱体的高度和半径,以及网格的精细度。基本的代码为[X, Y, Z] = cylinder(n);surf(X, Y, Z)。其中,n:一个正整数,表示生成的网格的精细度。n越大,网格越精细。X、Y、Z:分别代表圆柱体表面的坐标点。

The cylinder function is used to draw a cylinder. It generates a surface mesh of the cylinder, allowing the user to specify the height and radius of the cylinder, as well as the fineness of the mesh. The basic code is [X, Y, Z] = cylinder(n);surf(X, Y, Z). Among them, n: a positive integer, indicating the fineness of the generated mesh. The larger n is, the finer the mesh. X, Y, Z: represent the coordinate points on the surface of the cylinder respectively.

(4) peaks函数(peaks function)

MATLAB中的peaks函数用于生成一个包含多个山峰形状的二维矩阵,这个矩阵通常用于测试和演示各种数值方法,比如插值、数值积分、数值微分、优化算法等。peaks函数生成的矩阵通常被称为"peaks"函数的图形或数据。与其他函数不同的是,peaks函数不需要输入参数,它默认生成一个大小为17x17的矩阵。

The peaks function in MATLAB is used to generate a two-dimensional matrix containing multiple peak shapes. This matrix is often used to test and demonstrate various numerical methods, such as interpolation, numerical integration, numerical differentiation, optimization algorithms, etc. The matrix generated by the peaks function is often referred to as the graph or data of the "peaks" function. Unlike other functions, the peaks function does not require input parameters and generates a matrix of size 17x17 by default.

今天的分享就到这里了。

如果您对文章有独特的想法,

欢迎给我们留言,

让我们相约明天。

祝您今天过得开心快乐!

That's all for today'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 nice day!

翻译:谷歌翻译

参考资料:百度、CSDN博客

本文由LearningYard学苑整理发出,如有侵权请在后台留言!

文案|hzy

排版|hzy

审核|yyz

相关推荐

Excel批量生成随机人名_excel批量生成随机数

之前的文章讲过怎么用在Excel生成随机银行名字。今天继续给大家分享下怎么在Excel生成随机人名。随机数据工具包书接上回,本文对之前的随机数据生成工具包进行封装调用,生成的结果直接写入到Excel表...

一学就会:Excel MOD函数,让数字周期循环变得easy

今日推荐:MOD函数。目的:根据当前日期在年内的周数对5个小组取余,再根据余数的值获取对应的值班小组。MOD函数也可以作为获取随机数的一种,只不过这种随机数是有一定规律的。【函数介绍】MOD——返回两...

1条公式,自动随机分配座位,你会么?

随机座位困局、老办法效率低、新公式能否破局?.上周学校开会说要给教室换排座位,教务处老师愁得头发都快白了。以前都是靠老师自己写名单再划拉划分组,现在新教室三列座位,学生又多,折腾了三天都没摆顺当。听说...

excel快速制作姓名随机分配表_姓名随机分组

快速制作随机分配表。当需要把这一列的姓名进行随机分组应该怎么操作?是不是还在一行一行的去复制粘贴,这样效率是非常慢的。怎么快速的制作一个随机的分组?·首先在第一组输入等于第一个姓名的A2单元格,双击填...

Excel里实现随机分组案例:导入名单随机分组

大家好呀,今天来给大家分享如何快速在Excel里实现随机分组。如下图所示,有15个人,现在要随机分成3组,每组5个人。只要简单两步,就能完成分组。第一步:为每个人设置一个随机数并编序号C列输入公式=R...

办公必备的15个Excel技巧,绝对的硬核干货,收藏备用

Excel的灵魂在于数据的分析与统计,而分析与统计就离不开函数或公式,今天要给大家分享的15个函数公式,是工作中常用的,可以直接套用。一、从身份证号码中提取出生年月。函数1:Tex...

Excel如何将某单元格区域数据随机排序

如下图是某公司人员名单,现在想要对这些员工进行随机分组。即对单元格区域内数据进行随机排序。选中B2:E10单元格区域点击下图选项(Excel工具箱,百度它即可了解详细的下载安装方法,本文这里就不做具体...

一键生成随机口算题,Excel工具妙用

小学生每天都要做口算,今天我给大家分享一下如何用excel来自制小学生的口算题。看我这里已经做好了,它的公式是这样,然后往下去拉,想要多少要多少,而且每一道题都是随机的。而且这一个表做好了之后,只要让...

Excel秒变抽签神器!1分钟搞定随机点名/抽奖

还在为年会抽奖、课堂点名、分组任务抓狂?别求人写代码啦!Excel自带隐藏大招1分钟设置,永久使用,按个键就能开抽超简单3步设置(有手就会版)1随机号生成在姓名表旁新建「随机号」列输入=RAND...

基础函数20例,案例解读,再不掌握就真的Out了

Excel中的函数是Excel的一个重要工具,如果你不及时掌握,对于Excel的应用、工作效率等会受到很大的影响,今天,小编给大家分享20个Excel的基础函数,对大家肯定很有帮助。练习文件在文末领取...

怎么利用Excel实现随机取样_excel随机取数据

今天跟大家分享一下Excel如何随机抽样1.打开Excel软件2.选中要抽取数据的单元格区域3.点击下图选项(Excel工具箱,百度即可了解详细下载安装信息,本文这里就不做详细解说。)4.点击【统计与...

1分钟学会Excel总表更新,分表实时同步,再也不用熬夜了!

你是不是还在用筛选→复制→粘贴的老方法拆分Excel数据?每次按类别整理报表都要折腾半小时?别傻了!今天教你用FILTER函数一键搞定,数据更新还能自动同步!第一步:准备工作表新建3个工作表,分...

excel计算几个数范围,excel怎么计算一个范围的个数

excel怎么计算某些范围的数的个数,需要计算0-5,5-10,10-15,……1000的...比如这些数字在A列,从B1至B10求10个范围的数量。在B1输入:=countif(a:a,=10)在B...

让Excel随机排序_excel如何设置随机排序

随机排序如下图,希望对A列的应聘人员随机安排面试顺序。先将标题复制到右侧的空白单元格内,然后在第一个标题下方输入公式:=SORTBY(A2:B11,RANDARRAY(10),1)RANDARRAY的...

对人员进行随机分组,分步骤详细解释,看了就学会了

大家好,我是套路EXCEL!如上图,需要将12个人随机分成3组,每组4人。函数公式如下:=ROUNDUP(CHOOSECOLS(SORT(HSTACK(ROW(1:12),RANDARRAY(12...