1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 【 MATLAB 】Contour plot of matrix(矩阵的等高线图)

【 MATLAB 】Contour plot of matrix(矩阵的等高线图)

时间:2023-12-11 17:03:57

相关推荐

【 MATLAB 】Contour plot of matrix(矩阵的等高线图)

Contour plot of matrix

矩阵的等高线图

等高线图显示矩阵Z的等值线。使用clabel标记轮廓线。

contour(Z)绘制矩阵Z的等高线图,其中Z被解释为相对于x-y平面的高度。 Z必须至少是包含至少两个不同值的2乘2的矩阵。 x值对应于Z的列索引,y值对应于Z的行索引。自动选择轮廓级别。

contour(Z,n)绘制具有n个轮廓水平的矩阵Z的等高线图,其中n是标量。 自动选择轮廓水平。

contour(Z,v)绘制矩阵Z的等高线图,轮廓线位于单调增加矢量v中指定的数据值。要在特定值处显示单个轮廓线,请将v定义为具有两个元素的双元素矢量 等于所需的轮廓水平。 例如,要在级别k绘制轮廓线,请使用轮廓(Z,[k k])。 指定向量v会将LevelListMode属性设置为手动。

contour(X,Y,Z),contour(X,Y,Z,n), andcontour(X,Y,Z,v)draw contour plots ofZusingXandYto determine thexandyvalues.

IfXandYare vectors, thenlength(X)must equalsize(Z,2)andlength(Y)must equalsize(Z,1). The vectors must be strictly increasing or strictly decreasing and cannot contain any repeated values.

IfXandYare matrices, then their sizes must equal the size ofZ. Typically, you should setXandYso that the columns are strictly increasing or strictly decreasing and the rows are uniform (or the rows are strictly increasing or strictly decreasing and the columns are uniform).

IfXorYis irregularly spaced, thencontourcalculates contours using a regularly spaced contour grid, and then transforms the data toXorY.

如果 X 和 Y 是向量,则 length(X) 必须等于 size(Z,2),也即是Z的列数,length(Y) 必须等于 size(Z,1),也即是Z的行数。 向量必须严格增加或严格减少,并且不能包含任何重复值。

contour(...,LineSpec)使用LineSpec指定的线型和颜色绘制轮廓。 轮廓忽略标记符号。

contour(...,Name,Value)使用一个或多个属性名称,属性值对指定轮廓属性。 Name是属性名称,必须出现在单引号('')中。 值是相应的值。 例如,'LineWidth',2将轮廓线宽设置为2.有关轮廓属性名称和值的列表,请参见轮廓属性。

contour(ax,...)绘制到由ax指定的轴而不是当前轴(gca)。

[C,h] = contour(...)返回包含定义轮廓线的数据的轮廓矩阵C和Contour对象h。

Contour对象的ContourMatrix属性还包含轮廓矩阵。 clabel函数使用轮廓矩阵标记轮廓线。

使用“轮廓”对象属性可控制轮廓图外观。 有关列表,请参阅轮廓属性。

Create Contour Plot

Use the meshgrid function to generate matrices X and Y. Create a third matrix, Z, and plot its contours.

x = linspace(-2*pi,2*pi);y = linspace(0,4*pi);[X,Y] = meshgrid(x,y);Z = sin(X)+cos(Y);figurecontour(X,Y,Z)

Display Contour Labels

Set up matricesX,Y, andZ. Create a contour plot and display the contour labels by setting theShowTextproperty toon.

x = -2:0.2:2;y = -2:0.2:3;[X,Y] = meshgrid(x,y);Z = X.*exp(-X.^2-Y.^2);figurecontour(X,Y,Z,'ShowText','on')

Display Single Contour Line

Create a contour plot of thepeaksfunction and display only one contour level atZ = 1.

x = -3:0.125:3;y = -3:0.125:3;[X,Y] = meshgrid(x,y);Z = peaks(X,Y);v = [1,1];figurecontour(X,Y,Z,v)

Contour Properties

Contour chart appearance and behavior

Contourproperties control the appearance and behavior ofContourobjects. By changing property values, you can modify certain aspects of the contour chart.

轮廓属性控制Contour对象的外观和行为。 通过更改属性值,您可以修改等高线图的某些方面。

Starting in Rb, you can use dot notation to query and set properties.

[C,h] = contour(...);w = h.LineWidth;h.LineWidth = 2;

If you are using an earlier release, use thegetandsetfunctions instead.

Color and Styling

Fill—Fill between contour lines

'off'(default) |'on'

Fill between contour lines, specified as one of these values:

'off'— Do not fill the spaces between contour lines with a color. This is the default value when you create the contour chart using thecontourorcontour3functions.

'on'— Fill the spaces between contour lines with color. This is the default value when you create the contour chart using thecontourffunction.

LineColor—Color of contour lines

'flat'(default) |RGB triplet|'r'|'g'|'b'| ...

Color of contour lines, specified as'flat', an RGB triplet, or one of the color options listed in the table.

To use a different color for each contour line, specify'flat'. The colors are determined by the contour value of the line, the colormap, and the scaling of data values into the colormap. For more information on color scaling, seecaxis.

To use the same color for all contour lines, specify an RGB triplet or one of the color options listed in the table.

For a custom color, specify an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range[0,1]; for example,[0.4 0.6 0.7]. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.

LineStyle—Line style

'-'(default) |'--'|':'|'-.'|'none'

Line style, specified as one of the options listed in this table.

ShowText—Contour line labels

'off'(default) |'on'

Contour line labels, specified as one of these values:

'off'— Do not label the contour lines.

'on'— Display text labels on each contour line indicating the contour value.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。