Main Content

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

fimplicit3

绘制三维隐函数

  • Plot 3-D implicit function

说明

示例

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

示例

fimplicit3(f,interval)xyz 指定绘图区间。

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

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

示例

fimplicit3(___,Name,Value) 使用一个或多个名称-值对组参数指定曲面属性。例如,'FaceAlpha',0.6 为半透明曲面指定透明度值 0.6

示例

fs = fimplicit3(___) 返回 ImplicitFunctionSurface 对象。使用 fs 可在创建曲面后访问和修改曲面的属性。有关属性列表,请参阅 ImplicitFunctionSurface 属性

示例

全部折叠

xyz 的默认区间 [-5,5] 绘制双曲面 x2+y2-z2=0

f = @(x,y,z) x.^2 + y.^2 - z.^2;
fimplicit3(f)

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

对于 z,通过将绘图区间指定为 [0 5],绘制双曲面 x2+y2-z2=0 的上半部分。对于 xy,使用默认区间 [-5 5]

f = @(x,y,z) x.^2 + y.^2 - z.^2;
interval = [-5 5 -5 5 0 5];
fimplicit3(f,interval)

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

绘制隐曲面 x2+y2-z2=0。通过将 EdgeColor 属性设置为 'none' 删除线条。通过将 FaceAlpha 属性设置为 0 到 1 之间的值添加透明度。

f = @(x,y,z) x.^2 + y.^2 - z.^2;
fimplicit3(f,'EdgeColor','none','FaceAlpha',.5)

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

绘制隐曲面并将隐曲面对象赋给变量 fs

f = @(x,y,z) 1./x.^2 - 1./y.^2 + 1./z.^2;
fs = fimplicit3(f)

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

fs = 
  ImplicitFunctionSurface with properties:

     Function: @(x,y,z)1./x.^2-1./y.^2+1./z.^2
    EdgeColor: [0 0 0]
    LineStyle: '-'
    FaceColor: 'interp'

  Use GET to show all properties

使用 fs 在创建隐曲面后访问和修改其属性。例如,通过将 XRange 属性设置为 [0 5],只显示正 x 值。通过将 EdgeColor 属性设置为 'none' 删除线条。通过将 FaceAlpha 属性设置为 0.8 添加透明度。

fs.XRange = [0 5];
fs.EdgeColor = 'none';
fs.FaceAlpha = 0.8;

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

输入参数

全部折叠

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

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

示例: fimplicit3(@(x,y,z) x.^2 + y.^2 - z.^2)

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

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

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

示例: fimplicit3(f,[-2 3 -4 5 -3 3])

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

示例: "--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

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

名称-值参数

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

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

示例: fimplicit3(f,'MeshDensity',50,'FaceAlpha',0.5) 指定计算点数和透明度值。

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

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

面透明度,指定为 [0,1] 范围中的标量。在所有面上使用统一的透明度。值为 1 时完全不透明,值为 0 时完全透明。介于 01 之间的值表示半透明。

面颜色,指定为 'interp'、RGB 三元组、十六进制颜色代码、颜色名称或短名称。默认值 'interp' 将基于 ZData 的值进行颜色插值。

对于自定义颜色,请指定 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

线条颜色,指定为 'interp'、RGB 三元组、十六进制颜色代码、颜色名称或短名称。默认的 RGB 三元组值 [0 0 0] 与黑色对应。值 'interp' 将基于 ZData 的值为边着色。

对于自定义颜色,请指定 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

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

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

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 英寸。如果该线条具有标记,则线条宽度也会影响标记边。

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

提示

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

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

版本历史记录

在 R2016b 中推出