Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

fimplicit

绘制隐函数

  • Plot implicit function

说明

示例

fimplicit(f) 在默认区间 [-5 5](对于 xy)上绘制 f(x,y) = 0 定义的隐函数。

示例

fimplicit(f,interval)xy 指定绘图区间。

fimplicit(ax,___) 将在 ax 指定的坐标区中,而不是在当前坐标区中绘制图形。将坐标区指定为第一个输入参数,先于上述任何输入参数。

示例

fimplicit(___,LineSpec) 指定线型、标记符号和线条颜色。例如,'-r' 绘制一根红色线条。

示例

fimplicit(___,Name,Value) 使用一个或多个名称-值对组参数指定线条属性。例如,'LineWidth',2 指定 2 磅的线宽。

示例

fp = fimplicit(___) 返回 ImplicitFunctionLine 对象。使用 fp 可在创建线条后访问和修改线条属性。有关属性列表,请参阅 ImplicitFunctionLine 属性

示例

全部折叠

xy 的默认区间 [-5 5] 绘制由函数 x2-y2-1=0 描述的双曲线。

fimplicit(@(x,y) x.^2 - y.^2 - 1)

Figure contains an axes object. The axes object contains an object of type implicitfunctionline.

x[-3 0] 区间和 y[-2 2] 区间绘制函数 x2+y2-3=0

f = @(x,y) x.^2 + y.^2 - 3;
fimplicit(f,[-3 0 -2 2])

Figure contains an axes object. The axes object contains an object of type implicitfunctionline.

使用不同的半径值绘制两个以 (0,0) 为中心的圆。第一个圆使用红色点线。第二个圆使用线宽为 2 磅的绿色虚线。

f1 = @(x,y) x.^2 + y.^2 - 1;
fimplicit(f1,':r')

hold on
f2 = @(x,y) x.^2 + y.^2 - 2;
fimplicit(f2,'--g','LineWidth',2)
hold off

Figure contains an axes object. The axes object contains 2 objects of type implicitfunctionline.

绘制隐函数 ysin(x)+xcos(y)-1=0 并将隐函数线条对象赋给变量 fp

fp = fimplicit(@(x,y) y.*sin(x) + x.*cos(y) - 1)

Figure contains an axes object. The axes object contains an object of type implicitfunctionline.

fp = 
  ImplicitFunctionLine with properties:

     Function: @(x,y)y.*sin(x)+x.*cos(y)-1
        Color: [0 0.4470 0.7410]
    LineStyle: '-'
    LineWidth: 0.5000

  Use GET to show all properties

使用 fp 可在创建隐函数行对象后访问并修改其属性。例如,更改颜色、线型和线宽。

fp.Color = 'r';
fp.LineStyle = '--';
fp.LineWidth = 2;

Figure contains an axes object. The axes object contains an object of type implicitfunctionline.

输入参数

全部折叠

要绘制的隐函数,指定为命名或匿名函数的函数句柄。

指定 z = f(x,y) 形式的函数。该函数必须接受两个矩阵输入参数,并返回大小相同的矩阵输出参数。为获得最佳性能,应使用数组运算符而不是矩阵运算符。例如,使用 .* (times) 而不是 * (mtimes)。

示例: fimplicit(@(x,y) x.^2 - y.^2 + 1)

xy 的绘图区间,指定为下列形式之一:

  • [min max] 形式的二元素向量 - 对 xy 使用相同的绘图区间 [min max]

  • [xmin xmax ymin ymax] 形式的四元素向量 - 对 xy 使用不同的绘图区间。在区间 [xmin xmax](对于 x)和 [ymin ymax](对于 y)上绘图。

示例: fimplicit(f,[-2 3 -5 0])

线型、标记和颜色,指定为包含符号的字符串标量或字符向量。符号可以按任意顺序显示。您不需要同时指定所有三个特征(线型、标记和颜色)。例如,如果忽略线型,只指定标记,则绘图只显示标记,不显示线条。

示例: "--or" 是带有圆形标记的红色虚线。

线型描述表示的线条
"-"实线

Sample of solid line

"--"虚线

Sample of dashed line

":"点线

Sample of dotted line

"-."点划线

Sample of dash-dotted line, with alternating dashes and dots

标记描述生成的标记
"o"圆圈

Sample of circle marker

"+"加号

Sample of plus sign marker

"*"星号

Sample of asterisk marker

"."

Sample of point marker

"x"叉号

Sample of cross marker

"_"水平线条

Sample of horizontal line marker

"|"垂直线条

Sample of vertical line marker

"square"方形

Sample of square marker

"diamond"菱形

Sample of diamond marker

"^"上三角

Sample of upward-pointing triangle marker

"v"下三角

Sample of downward-pointing triangle marker

">"右三角

Sample of right-pointing triangle marker

"<"左三角

Sample of left-pointing triangle marker

"pentagram"五角形

Sample of pentagram marker

"hexagram"六角形

Sample of hexagram marker

颜色名称短名称RGB 三元组外观
"red""r"[1 0 0]

Sample of the color red

"green""g"[0 1 0]

Sample of the color green

"blue""b"[0 0 1]

Sample of the color blue

"cyan" "c"[0 1 1]

Sample of the color cyan

"magenta""m"[1 0 1]

Sample of the color magenta

"yellow""y"[1 1 0]

Sample of the color yellow

"black""k"[0 0 0]

Sample of the color black

"white""w"[1 1 1]

Sample of the color white

坐标区对象。如果您不指定坐标区,则 fimplicit 使用当前坐标区。

名称-值参数

将可选的参数对组指定为 Name1=Value1,...,NameN=ValueN,其中 Name 是参数名称,Value 是对应的值。名称-值参数必须出现在其他参数之后,但参数对组的顺序无关紧要。

在 R2021a 之前,使用逗号分隔每个名称和值,并用引号将 Name 引起来。

示例: fimplicit(f,'MeshDensity',50,'LineWidth',2) 指定计算点数和线宽。

此处所列的 ImplicitFunctionLine 属性只是一部分。有关完整列表,请参阅 ImplicitFunctionLine 属性

每个方向上的计算点数,指定为标量。

线条颜色,指定为 RGB 三元组、十六进制颜色代码、颜色名称或短名称。

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

  • RGB 三元组是包含三个元素的行向量,其元素分别指定颜色中红、绿、蓝分量的强度。强度值必须位于 [0,1] 范围内,例如 [0.4 0.6 0.7]

  • 十六进制颜色代码是字符串标量或字符向量,以井号 (#) 开头,后跟三个或六个十六进制数字,范围可以是 0F。这些值不区分大小写。因此,颜色代码 "#FF8800""#ff8800""#F80""#f80" 是等效的。

此外,还可以按名称指定一些常见的颜色。下表列出了命名颜色选项、等效 RGB 三元组和十六进制颜色代码。

颜色名称短名称RGB 三元组十六进制颜色代码外观
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan" "c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"不适用不适用不适用无颜色

以下是 MATLAB® 在许多类型的绘图中使用的默认颜色的 RGB 三元组和十六进制颜色代码。

RGB 三元组十六进制颜色代码外观
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[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"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

示例: 'blue'

示例: [0 0 1]

示例: '#0000FF'

线型,指定为下表中列出的选项之一。

线型描述表示的线条
"-"实线

Sample of solid line

"--"虚线

Sample of dashed line

":"点线

Sample of dotted line

"-."点划线

Sample of dash-dotted line, with alternating dashes and dots

"none"无线条无线条

线宽,指定为以磅为单位的正值,其中 1 磅 = 1/72 英寸。如果该线条具有标记,则线条宽度也会影响标记边。

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

标记符号,指定为下表中列出的值之一。默认情况下,对象不显示标记。指定标记符号可在每个数据点或顶点添加标记。

标记描述生成的标记
"o"圆圈

Sample of circle marker

"+"加号

Sample of plus sign marker

"*"星号

Sample of asterisk marker

"."

Sample of point marker

"x"叉号

Sample of cross marker

"_"水平线条

Sample of horizontal line marker

"|"垂直线条

Sample of vertical line marker

"square"方形

Sample of square marker

"diamond"菱形

Sample of diamond marker

"^"上三角

Sample of upward-pointing triangle marker

"v"下三角

Sample of downward-pointing triangle marker

">"右三角

Sample of right-pointing triangle marker

"<"左三角

Sample of left-pointing triangle marker

"pentagram"五角形

Sample of pentagram marker

"hexagram"六角形

Sample of hexagram marker

"none"无标记不适用

标记大小,指定为以磅为单位的正值,其中 1 磅 = 1/72 英寸。

标记轮廓颜色,指定为 "auto"、RGB 三元组、十六进制颜色代码、颜色名称或短名称。默认值 "auto" 使用与 Color 属性相同的颜色。

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

  • RGB 三元组是包含三个元素的行向量,其元素分别指定颜色中红、绿、蓝分量的强度。强度值必须位于 [0,1] 范围内,例如 [0.4 0.6 0.7]

  • 十六进制颜色代码是字符串标量或字符向量,以井号 (#) 开头,后跟三个或六个十六进制数字,范围可以是 0F。这些值不区分大小写。因此,颜色代码 "#FF8800""#ff8800""#F80""#f80" 是等效的。

此外,还可以按名称指定一些常见的颜色。下表列出了命名颜色选项、等效 RGB 三元组和十六进制颜色代码。

颜色名称短名称RGB 三元组十六进制颜色代码外观
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan" "c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"不适用不适用不适用无颜色

以下是 MATLAB 在许多类型的绘图中使用的默认颜色的 RGB 三元组和十六进制颜色代码。

RGB 三元组十六进制颜色代码外观
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[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"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

标记填充颜色,指定为 'auto'、RGB 三元组、十六进制颜色代码、颜色名称或短名称。'auto' 值使用与 MarkerEdgeColor 属性相同的颜色。

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

  • RGB 三元组是包含三个元素的行向量,其元素分别指定颜色中红、绿、蓝分量的强度。强度值必须位于 [0,1] 范围内,例如 [0.4 0.6 0.7]

  • 十六进制颜色代码是字符串标量或字符向量,以井号 (#) 开头,后跟三个或六个十六进制数字,范围可以是 0F。这些值不区分大小写。因此,颜色代码 "#FF8800""#ff8800""#F80""#f80" 是等效的。

此外,还可以按名称指定一些常见的颜色。下表列出了命名颜色选项、等效 RGB 三元组和十六进制颜色代码。

颜色名称短名称RGB 三元组十六进制颜色代码外观
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan" "c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"不适用不适用不适用无颜色

以下是 MATLAB 在许多类型的绘图中使用的默认颜色的 RGB 三元组和十六进制颜色代码。

RGB 三元组十六进制颜色代码外观
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[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"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

示例: [0.3 0.2 0.1]

示例: 'green'

示例: '#D2F9A7'

提示

  • 为了获得最佳性能和避免产生警告消息,请使用按元素运算符。例如,使用 x.*y 而不是 x*y。有关详细信息,请参阅数组与矩阵运算

  • 放大图形时,fimplicit 将重新计算数据,这样可以显示隐藏的详细信息。

版本历史记录

在 R2016b 中推出