主要内容

fplot

阴谋符号表达or function

描述

例子

fplot(F绘制符号输入F默认间隔[-5 5]

例子

fplot(F,,,,[Xmin Xmax]plotsF超过the interval[Xmin Xmax]

例子

fplot(XT,,,,plotsXT=X((tand=y((t超过默认范围的t,那是[–5 5]

fplot(XT,,,,,,,,[tmin tmax]plotsXT=X((tand=y((t超过指定范围[tmin tmax]

例子

fplot(___,,,,LinesPecusesLinesPecto set the line style, marker symbol, and line color.

例子

fplot(___,,,,名称,价值使用一个或多个指定行属性名称,价值配对参数。将此选项与上一个语法中的任何输入参数组合一起使用。名称,价值pair settings apply to all the lines plotted. To set options for individual lines, use the objects returned byfplot

fplot(斧头,,,,___图到指定的轴斧头而不是当前轴GCA

例子

fp=fplot(___根据图的类型返回函数线对象或参数化行对象。使用对象查询和修改特定行的属性。有关详细信息,请参阅FunctionLine PropertiesandParameterizedFunctionLine Properties

例子

绘制符号表达

阴谋棕褐色(x)超过默认范围的[-5 5]fplot默认情况下显示电线杆。有关详细信息,请参阅showPoles参数名称值对参数

符号Xfplot(棕褐色(x))

图包含一个轴对象。The axes object contains an object of type functionline.

阴谋symbolic Function

阴谋the symbolic function F (( X = cos (( X 超过默认范围[-5 5]

符号F(x)f(x)= cos(x);fplot(f)

图包含一个轴对象。The axes object contains an object of type functionline.

阴谋Parametric Curve

阴谋the parametric curve X = cos (( 3 t and y = (( 2 t

符号tX=cos(3*t); y = sin(2*t); fplot(x,y)

图包含一个轴对象。The axes object contains an object of type parameterizedfunctionline.

specify Plotting Interval

阴谋 (( X 超过 [[ - π / 2 ,,,, π / 2 这是给予的 通过将绘图间隔指定为第二个输入fplot

符号Xfplot(罪(x),,,,[[-pi/2 pi/2])

图包含一个轴对象。The axes object contains an object of type functionline.

在同一图上绘制多行

您可以通过将输入作为向量或使用来绘制多行hold on连续绘制同一图。如果指定LinesPecand Name-Value arguments, they apply to all lines. To set options for individual plots, use the function handles returned byfplot

Divide a figure into two subplots using子图。On the first subplot, plot (( X and cos (( X using vector input. On the second subplot, plot (( X and cos (( X usinghold on

符号X子图(2,1,1)fplot([[sin(x)cos(x)])标题(“使用向量输入的多行”)子图(2,1,2)fplot(sin(x))保持onfplot(cos(x))标题('Multiple Lines Using hold on Command')holdoff

F一世gure contains 2 axes objects. Axes object 1 with title Multiple Lines Using Vector Inputs contains 2 objects of type functionline. Axes object 2 with title Multiple Lines Using hold on Command contains 2 objects of type functionline.

更改行属性和显示标记

在每条线之间绘制三个正弦曲线。对于第一行,使用一条线宽2。第二个,指定带有圆形标记的虚线红线样式。对于第三个,请指定带有星号标记的青色仪表板线样式。显示传奇。

符号Xfplot(sin(x+pi/5),'行宽',2)保持onfplot(罪((X-pi/5),' - 或者')fplot(sin(x),'-.*c') 传奇('节目',,,,'Location',,,,'最好的')holdoff

图包含一个轴对象。轴对象包含3个类型函数线的对象。

情节的控制分辨率

通过使用MeshDensityoption. IncreasingMeshDensity可以使更光滑,更准确的图可以提高绘图速度。

Divide a figure into two by using子图。在第一个子图中,从x = 2.1tox = 2.15。该图的分辨率太低,无法检测步骤函数。通过增加此问题MeshDensityto39在第二个子图中。该图现在检测到步骤函数,并通过增加MeshDensityyou increased the plot's resolution.

符号XstepFn = rectangularPulse(2.1, 2.15, x); subplot(2,1,1) fplot(stepFn); title('Default MeshDensity = 23')子图(2,1,2)FPLOT(Stepfn,“网状密度”,39);标题('网格密度= 39'

F一世gure contains 2 axes objects. Axes object 1 with title Default MeshDensity = 23 contains an object of type functionline. Axes object 2 with title Increased MeshDensity = 39 contains an object of type functionline.

Modify Plot After Creation

阴谋罪(x)。指定输出以进行fplot返回绘图对象。

符号Xh = fplot(sin(x))

图包含一个轴对象。The axes object contains an object of type functionline.

h = FunctionLine with properties: Function: sin(x) Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Show all properties

通过使用点符号设置属性,将默认蓝线更改为虚线的红线。同样,添加'X'markers and set the marker color to blue.

h.linestyle =' - ';h.Color ='r';H.Marker ='X';H.MarkeredGecolor ='b';

图包含一个轴对象。The axes object contains an object of type functionline.

Add Title and Axis Labels and Format Ticks

为了 X - 2 π to 2 π , 阴谋 (( X 。Add a title and axis labels. Create the x-axis ticks by spanning the x-axis limits at intervals ofpi/2。通过使用XTICK财产。通过使用arrayfun申请德州人tos。通过使用Xticklabel财产。

To use LaTeX in plots, see乳胶

符号Xfplot(罪(x),,,,[[-2*pi 2*pi]) gridon标题('sin(x)从-2 \ pi到2 \ pi')Xlabel('X')ylabel('y')ax = gca;s = sym(ax.xlim(1):pi/2:ax.xlim(2));ax.xtick = double(s);ax.xticklabel = arrayfun(@texlabel,s,'UniformOutput',,,,False);

图包含一个轴对象。带有标题s i n(x)空白的轴对象空白-2 pi blank t o blank 2 pi包含一个类型函数线的对象。

重新评估Zoom

当您放大情节时,fplot自动重新评估图。这种重新评估在缩放下揭示了较小尺度的隐藏细节。

阴谋X^3*sin(1/x)为了-2 and-0.02 。Zoom in on the plot usingzoom并使用绘制。由于重新评估Zoom,fplot揭示较小的细节。重复6次缩放以查看较小规模的细节。要播放动画,请单击图像。

符号Xfplot(X^3*sin(1/x)); axis([-2 2 -0.02 0.02]);为了i = 1:6变焦(1.7)暂停(0.5)结尾

Create Animations

通过使用Function,,,,XFunction,,,,and函数属性,然后使用绘制更新图。要导出到GIF,请参阅一世mwrite

By varying the variable一世从0。1to 3, animate the parametric curve

X = 一世 t (( 一世 t y = 一世 t cos (( 一世 t

要播放动画,请单击图像。

符号tfp = fplot(t,t);轴([ -  15 15 -15 15])为了i = 0.1:0.05:3 fp.xfunction = i。*t。*sin(i*t);fp.yfunction = i。*t。*cos(i*t);绘制结尾

输入参数

全部收缩

绘制的表达式或功能,指定为符号表达式或函数。

X坐标的绘图间隔,,,,specified as a vector of two numbers. The default range is[-5 5]。但是,如果fplot检测到有限数量的不连续性F, 然后fplot扩展范围以显示它们。

Parametric input for x-coordinates, specified as a symbolic expression or function.fplotusesSymvarto find the parameter.

Y轴的参数输入,指定为符号表达式或函数。fplotusesSymvarto find the parameter.

参数值范围t,,,,specified as a vector of two numbers. The default range is[-5 5]

轴对象。如果you do not specify an axes object, thenfplot使用当前轴GCA

Line style, marker, and color, specified as a character vector or string containing symbols. The symbols can appear in any order. You do not need to specify all three characteristics (line style, marker, and color). For example, if you omit the line style and specify the marker, then the plot shows only the marker and no line.

例子:' - 或者'是带有圆形标记的红色虚线

线样式 描述 结果线
' - ' solid line

实线样品

' - ' 虚线

sample of dashed line

':' 虚线

虚线样品

' - 。' 破折号线

仪表板点线样本,带有交替的破折号和点

标记 描述 Resulting Marker
'o' 圆圈

sample of circle marker

'+' Plus sign

加号标记样品

'*' 星号

星号标记样品

'。' Point

sample of point marker

'X' Cross

跨标记样本

'_' Horizontal line

sample of horizontal line marker

'|' Vertical line

sample of vertical line marker

' 正方形

sample of square marker

'D' 钻石

sample of diamond line marker

'^' Upward-pointing triangle

向上的三角标记样本

'v' 向下三角形

sample of downward-pointing triangle marker

'>' 右点三角形

右点三角形标记的样本

'<' 左点三角形

sample of left-pointing triangle marker

'P' Pentagram

五角星标记样品

'H' hexagram

sample of hexagram marker

颜色名称 简称 RGB三胞胎 Appearance
'红色的' 'r' [[100这是给予的

sample of the color red

'绿色' 'G' [0 1 0]

颜色绿色样品

'蓝色的' 'b' [[001这是给予的

蓝色样品

'cyan' 'c' [0 1 1]

颜色青色样品

'magenta' 'm' [[101这是给予的

颜色洋红色样品

'黄色的' 'y' [1 1 0]

黄色样品

'black' 'K' [[000这是给予的

sample of the color black

'白色的' 'W' [1 1 1]

颜色样品白色

名称值参数

specify optional pairs of arguments asname1 = value1,...,namen = valuen, 在哪里姓名是参数名称和Value是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。

Before R2021a, use commas to separate each name and value, and enclose姓名用引号。

例子:“标记”,“ O”,“ MarkerfaceColor”,“红色”

此处列出的功能线属性只是子集。有关完整列表,请参阅FunctionLine Properties

评估点的数量,指定为数字。默认值为23。Becausefplot使用自适应评估,评估点的实际数量更大。

Display asymptotes at poles, specified as'上'or'离开',或数字或逻辑1((true) 或者0((错误的)。一个值'上'等同于true, and'离开'等同于错误的。因此,您可以将此属性的值用作逻辑值。该值存储为类型的ON/OFF逻辑值matlab.lang.onoffswitchstate

渐近线显示为灰色,虚线。fplot仅与fplot(f)语法或变体,而不是FPLOT(XT,YT)句法。

线色颜色,指定为RGB三重态,十六进制的颜色代码,颜色名称或短名称。

对于自定义颜色,请指定RGB三重态或十六进制颜色代码。

  • 一个RGB值是一个行向量的三元素elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range[0,1];为了例子,,,,[[0。4 0.6 0.7]

  • 十六进制的颜色代码是字符向量或字符串标量,以哈希符号开头(),然后是三个或六个十六进制的数字,范围从0toF。The values are not case sensitive. Thus, the color codes'#FF8800',,,,'#ff8800',,,,'#F80',,,,and'#f80'是等效的。

另外,您可以按名称指定一些常见的颜色。该表列出了命名的颜色选项,等效的RGB三重态和十六进制颜色代码。

颜色名称 简称 RGB三胞胎 十六进制的颜色代码 Appearance
'红色的' 'r' [[100这是给予的 '#ff0000'

sample of the color red

'绿色' 'G' [0 1 0] '#00ff00'

颜色绿色样品

'蓝色的' 'b' [[001这是给予的 '#0000FF'

蓝色样品

'cyan' 'c' [0 1 1] '#00ffff'

颜色青色样品

'magenta' 'm' [[101这是给予的 '#ff00ff'

颜色洋红色样品

'黄色的' 'y' [1 1 0] '#ffff00'

黄色样品

'black' 'K' [[000这是给予的 '#000000'

sample of the color black

'白色的' 'W' [1 1 1] '#ffffff'

颜色样品白色

这是RGB三胞胎和默认颜色的十六进制颜色代码matlab®uses in many types of plots.

RGB三胞胎 十六进制的颜色代码 Appearance
[0 0.4470 0.7410] '#0072BD'

RGB三重态样品[0 0.4470 0.7410],显示为深蓝色

[0.8500 0.3250 0.0980] '#D95319'

RGB三重态样品[0.8500 0.3250 0.0980],如深橙色

[0.9290 0.6940 0.1250] '#EDB120'

sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[[0。4940 0.1840 0.5560] '#7E2F8E'

RGB三重态样品[0.4940 0.1840 0.5560]

[0.4660 0.6740 0.1880] '#77AC30'

RGB三重态样品[0.4660 0.6740 0.1880],该样本如中等绿色

[[0。30100。7450 0.9330] '#4DBEEE'

RGB三胞胎样品[0.3010 0.7450 0.9330],如浅蓝色

[[0。6350 0.0780 0.1840] '#a2142f'

RGB三重态样品[0.6350 0.0780 0.1840],看起来为深红色

例子:'蓝色的'

例子:[[001这是给予的

例子:'#0000FF'

线样式,指定为此表中列出的选项之一。

线样式 描述 结果线
' - ' solid line

实线样品

' - ' 虚线

sample of dashed line

':' 虚线

虚线样品

' - 。' 破折号线

仪表板点线样本,带有交替的破折号和点

'没有任何' 没有行 没有行

Line width, specified as a positive value in points, where 1 point = 1/72 of an inch. If the line has markers, then the line width also affects the marker edges.

线宽度不能比像素的宽度更薄。如果将线路宽度设置为小于系统上像素宽度的值,则该线将显示为一个像素宽。

标记symbol, specified as one of the values listed in this table. By default, the object does not display markers. Specifying a marker symbol adds markers at each data point or vertex.

标记 描述 Resulting Marker
'o' 圆圈

sample of circle marker

'+' Plus sign

加号标记样品

'*' 星号

星号标记样品

'。' Point

sample of point marker

'X' Cross

跨标记样本

'_' Horizontal line

sample of horizontal line marker

'|' Vertical line

sample of vertical line marker

' 正方形

sample of square marker

'D' 钻石

sample of diamond line marker

'^' Upward-pointing triangle

向上的三角标记样本

'v' 向下三角形

sample of downward-pointing triangle marker

'>' 右点三角形

右点三角形标记的样本

'<' 左点三角形

sample of left-pointing triangle marker

'P' Pentagram

五角星标记样品

'H' hexagram

sample of hexagram marker

'没有任何' No markers 不适用

标记大纲颜色,指定为'汽车',,,,an RGB triplet, a hexadecimal color code, a color name, or a short name. The default value of'汽车'使用与颜色财产。

对于自定义颜色,请指定RGB三重态或十六进制颜色代码。

  • 一个RGB值是一个行向量的三元素elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range[0,1];为了例子,,,,[[0。4 0.6 0.7]

  • 十六进制的颜色代码是字符向量或字符串标量,以哈希符号开头(),然后是三个或六个十六进制的数字,范围从0toF。The values are not case sensitive. Thus, the color codes'#FF8800',,,,'#ff8800',,,,'#F80',,,,and'#f80'是等效的。

另外,您可以按名称指定一些常见的颜色。该表列出了命名的颜色选项,等效的RGB三重态和十六进制颜色代码。

颜色名称 简称 RGB三胞胎 十六进制的颜色代码 Appearance
'红色的' 'r' [[100这是给予的 '#ff0000'

sample of the color red

'绿色' 'G' [0 1 0] '#00ff00'

颜色绿色样品

'蓝色的' 'b' [[001这是给予的 '#0000FF'

蓝色样品

'cyan' 'c' [0 1 1] '#00ffff'

颜色青色样品

'magenta' 'm' [[101这是给予的 '#ff00ff'

颜色洋红色样品

'黄色的' 'y' [1 1 0] '#ffff00'

黄色样品

'black' 'K' [[000这是给予的 '#000000'

sample of the color black

'白色的' 'W' [1 1 1] '#ffffff'

颜色样品白色

'没有任何' 不适用 不适用 不适用 没有颜色

这是MATLAB在许多类型的图中使用的默认颜色的RGB三重态和十六进制颜色代码。

RGB三胞胎 十六进制的颜色代码 Appearance
[0 0.4470 0.7410] '#0072BD'

RGB三重态样品[0 0.4470 0.7410],显示为深蓝色

[0.8500 0.3250 0.0980] '#D95319'

RGB三重态样品[0.8500 0.3250 0.0980],如深橙色

[0.9290 0.6940 0.1250] '#EDB120'

sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[[0。4940 0.1840 0.5560] '#7E2F8E'

RGB三重态样品[0.4940 0.1840 0.5560]

[0.4660 0.6740 0.1880] '#77AC30'

RGB三重态样品[0.4660 0.6740 0.1880],该样本如中等绿色

[[0。30100。7450 0.9330] '#4DBEEE'

RGB三胞胎样品[0.3010 0.7450 0.9330],如浅蓝色

[[0。6350 0.0780 0.1840] '#a2142f'

RGB三重态样品[0.6350 0.0780 0.1840],看起来为深红色

标记F一世ll color, specified as'汽车',,,,an RGB triplet, a hexadecimal color code, a color name, or a short name. The'汽车'value uses the same color as the标记EdgeColor财产。

对于自定义颜色,请指定RGB三重态或十六进制颜色代码。

  • 一个RGB值是一个行向量的三元素elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range[0,1];为了例子,,,,[[0。4 0.6 0.7]

  • 十六进制的颜色代码是字符向量或字符串标量,以哈希符号开头(),然后是三个或六个十六进制的数字,范围从0toF。The values are not case sensitive. Thus, the color codes'#FF8800',,,,'#ff8800',,,,'#F80',,,,and'#f80'是等效的。

另外,您可以按名称指定一些常见的颜色。该表列出了命名的颜色选项,等效的RGB三重态和十六进制颜色代码。

颜色名称 简称 RGB三胞胎 十六进制的颜色代码 Appearance
'红色的' 'r' [[100这是给予的 '#ff0000'

sample of the color red

'绿色' 'G' [0 1 0] '#00ff00'

颜色绿色样品

'蓝色的' 'b' [[001这是给予的 '#0000FF'

蓝色样品

'cyan' 'c' [0 1 1] '#00ffff'

颜色青色样品

'magenta' 'm' [[101这是给予的 '#ff00ff'

颜色洋红色样品

'黄色的' 'y' [1 1 0] '#ffff00'

黄色样品

'black' 'K' [[000这是给予的 '#000000'

sample of the color black

'白色的' 'W' [1 1 1] '#ffffff'

颜色样品白色

'没有任何' 不适用 不适用 不适用 没有颜色

这是MATLAB在许多类型的图中使用的默认颜色的RGB三重态和十六进制颜色代码。

RGB三胞胎 十六进制的颜色代码 Appearance
[0 0.4470 0.7410] '#0072BD'

RGB三重态样品[0 0.4470 0.7410],显示为深蓝色

[0.8500 0.3250 0.0980] '#D95319'

RGB三重态样品[0.8500 0.3250 0.0980],如深橙色

[0.9290 0.6940 0.1250] '#EDB120'

sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[[0。4940 0.1840 0.5560] '#7E2F8E'

RGB三重态样品[0.4940 0.1840 0.5560]

[0.4660 0.6740 0.1880] '#77AC30'

RGB三重态样品[0.4660 0.6740 0.1880],该样本如中等绿色

[[0。30100。7450 0.9330] '#4DBEEE'

RGB三胞胎样品[0.3010 0.7450 0.9330],如浅蓝色

[[0。6350 0.0780 0.1840] '#a2142f'

RGB三重态样品[0.6350 0.0780 0.1840],看起来为深红色

例子:[[0。30。20。1这是给予的

例子:'绿色'

例子:'#D2F9A7'

标记size, specified as a positive value in points, where 1 point = 1/72 of an inch.

输出参数

全部收缩

一个或多个函数或参数化函数线对象,返回为标量或向量。

  • 如果you use thefplot(f)语法或该语法的变体,然后fplotreturns function line objects.

  • 如果you use theFPLOT(XT,YT)语法或该语法的变体,然后fplot返回参数化线对象。

您可以使用这些对象查询和修改特定行的属性。有关属性列表,请参见FunctionLine PropertiesandParameterizedFunctionLine Properties

尖端

  • 如果fplot检测到有限数量的不连续性F, 然后fplot扩展范围以显示它们。

版本历史记录

在R2016a中引入