Main Content

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

fplot3

三维参数化曲线绘图函数

  • 3-D parametric curve plotter

说明

示例

fplot3(funx,funy,funz) 在默认区间 [-5,5](对于 t)绘制由 x = funx(t)y = funy(t)z = funz(t) 定义的参数化曲线。

示例

fplot3(funx,funy,funz,tinterval) 将在指定区间绘图。将区间指定为 [tmin tmax] 形式的二元素向量。

示例

fplot3(___,LineSpec) 设置线型、标记符号和线条颜色。例如,'-r' 指定红色线条。在前面的任何输入参数组合之后使用此选项。

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

fplot3(ax,___) 将图形绘制到 ax 指定的坐标区中,而不是当前坐标区中。指定坐标区作为第一个输入参数。

示例

fp = fplot3(___) 返回 ParameterizedFunctionLine 对象。可使用此对象查询和修改特定线条的属性。有关属性列表,请参阅 ParameterizedFunctionLine 属性

示例

全部折叠

绘制三维参数化线条

x=sin(t)y=cos(t)z=t

(在默认参数范围 [-5 5] 内。)

xt = @(t) sin(t);
yt = @(t) cos(t);
zt = @(t) t;
fplot3(xt,yt,zt)

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

绘制参数化线条

x=e-t/10sin(5t)y=e-t/10cos(5t)z=t

(通过指定 fplot3 的第四个输入实参,在形参范围 [-10 10] 内绘制)。

xt = @(t) exp(-t/10).*sin(5*t);
yt = @(t) exp(-t/10).*cos(5*t);
zt = @(t) t;
fplot3(xt,yt,zt,[-10 10])

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

在参数的不同区间,将同一条三维参数化曲线绘制三次。对于第一个区间,使用 2 磅的线宽。对于第二个,指定带有圆形标记的红色虚线线型。对于第三个,指定带有星号标记的青蓝色点划线线型。

fplot3(@(t)sin(t), @(t)cos(t), @(t)t, [0 2*pi], 'LineWidth', 2)
hold on
fplot3(@(t)sin(t), @(t)cos(t), @(t)t, [2*pi 4*pi], '--or')
fplot3(@(t)sin(t), @(t)cos(t), @(t)t, [4*pi 6*pi], '-.*c')
hold off

Figure contains an axes object. The axes object contains 3 objects of type parameterizedfunctionline.

使用 hold on 在相同的坐标区中绘制多个线条。

fplot3(@(t)t, @(t)t, @(t)t)
hold on
fplot3(@(t)-t, @(t)t, @(t)-t)
hold off

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

绘制参数化线条

x=e-|t|/10sin(5|t|)y=e-|t|/10cos(5|t|)z=t.

将参数化函数行对象指定给变量。

xt = @(t)exp(-abs(t)/10).*sin(5*abs(t));
yt = @(t)exp(-abs(t)/10).*cos(5*abs(t));
zt = @(t)t;
fp = fplot3(xt,yt,zt)

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

fp = 
  ParameterizedFunctionLine with properties:

    XFunction: @(t)exp(-abs(t)/10).*sin(5*abs(t))
    YFunction: @(t)exp(-abs(t)/10).*cos(5*abs(t))
    ZFunction: @(t)t
        Color: [0 0.4470 0.7410]
    LineStyle: '-'
    LineWidth: 0.5000

  Use GET to show all properties

将参数值范围更改为 [-10 10],并将线条颜色更改为红色。

fp.TRange = [-10 10];
fp.Color = 'r';

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

为从 -2π2π 范围内的 t 值绘制参数化线条

x=ty=t/2z=sin(6t).

添加标题、x 轴标签和 y 轴标签。此外,还可以更改坐标区视图并显示坐标区框轮廓。

xt = @(t)t;
yt = @(t)t/2;
zt = @(t)sin(6*t);
fplot3(xt,yt,zt,[-2*pi 2*pi],'MeshDensity',30,'LineWidth',1);

title('x=t, y=t/2, z=sin(6t) for -2\pi<t<2\pi')
xlabel('x');
ylabel('y');
view(52.5,30)
box on

Figure contains an axes object. The axes object with title x=t, blank y=t/2, blank z=sin(6t) blank for blank -2 pi <t<2 pi, xlabel x, ylabel y contains an object of type parameterizedfunctionline.

使用 gca 访问坐标区对象。使用坐标区对象的 XTickXTickLabel 属性指定 x 轴刻度值和关联的标签。按照同样的方式指定 y 轴刻度值和关联的标签。

ax = gca;
ax.XTick = -2*pi:pi/2:2*pi;
ax.XTickLabel = {'-2\pi','-3\pi/2','-\pi','-\pi/2','0',...
    '\pi/2','\pi','3\pi/2','2\pi'};

ax.YTick = -pi:pi/2:pi;
ax.YTickLabel = {'-\pi','-\pi/2','0','\pi/2','\pi'};

Figure contains an axes object. The axes object with title x=t, blank y=t/2, blank z=sin(6t) blank for blank -2 pi <t<2 pi, xlabel x, ylabel y contains an object of type parameterizedfunctionline.

输入参数

全部折叠

x 坐标的参数化函数,指定为命名或匿名函数的函数句柄。

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

示例: funx = @(t) sin(2*t);

y 坐标的参数化函数,指定为命名或匿名函数的函数句柄。

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

示例: funy = @(t) cos(2*t);

z 坐标的参数化函数,指定为命名或匿名函数的函数句柄。

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

示例: funz = @(t) t;

参数 t 的区间,指定为 [tmin tmax] 形式的二元素向量。

坐标区对象。如果您不指定坐标区对象,则 fplot3 使用当前坐标区 (gca)。

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

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

名称-值参数

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

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

示例: 'Marker','o','MarkerFaceColor','red'

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

计算点数,以数值形式指定。默认值为 23。由于 fplot3 使用自适应计算,因此实际的计算点数更大。

线条颜色,指定为 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

以下是 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"无标记不适用

标记轮廓颜色,指定为 "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'

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

输出参数

全部折叠

一个或多个 ParameterizedFunctionLine 对象,以标量或向量形式返回。您可以使用这些对象查询和修改特定 ParameterizedFunctionLine 对象的属性。有关详细信息,请参阅 ParameterizedFunctionLine 属性

版本历史记录

在 R2016a 中推出