Plot 3-D parametric curve - MATLAB fplot3 (2024)

Plot 3-D parametric curve

collapse all in page

Syntax

fplot3(xt,yt,zt)

fplot3(xt,yt,zt,[tmintmax])

fplot3(___,LineSpec)

fplot3(___,Name,Value)

fplot3(ax,___)

fp = fplot3(___)

Description

example

fplot3(xt,yt,zt) plotsthe parametric curve xt = x(t), yt = y(t),and zt = z(t)over the default interval –5<t<5.

example

fplot3(xt,yt,zt,[tmintmax]) plots xt = x(t), yt = y(t),and zt = z(t)over the interval tmin < t < tmax.

example

fplot3(___,LineSpec) uses LineSpec toset the line style, marker symbol, and line color.

example

fplot3(___,Name,Value) specifiesline properties using one or more Name,Value pairarguments. Use this option with any of the input argument combinationsin the previous syntaxes. Name,Value pair settingsapply to all the lines plotted. To set options for individual lines,use the objects returned by fplot3.

fplot3(ax,___) plotsinto the axes object ax instead of the currentaxes gca.

example

fp = fplot3(___) returnsa parameterized function line object. Use the object to query andmodify properties of a specific parameterized line. For details, see ParameterizedFunctionLine Properties.

Examples

collapse all

Plot 3-D Parametric Line

Open Live Script

Plot the 3-D parametric line

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

over the default parameter range [-5 5].

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

Plot 3-D parametric curve - MATLAB fplot3 (1)

Specify Parameter Range

Open Live Script

Plot the parametric line

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

over the parameter range [-10 10] by specifying the fourth argument of fplot3.

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

Plot 3-D parametric curve - MATLAB fplot3 (2)

Change Line Properties and Display Markers

Open Live Script

Plot the same 3-D parametric curve three times over different intervals of the parameter. For the first curve, use a linewidth of 2. For the second, specify a dashed red line style with circle markers. For the third, specify a cyan, dash-dot line style with asterisk markers.

syms tfplot3(sin(t), cos(t), t, [0 2*pi], 'LineWidth', 2)hold onfplot3(sin(t), cos(t), t, [2*pi 4*pi], '--or')fplot3(sin(t), cos(t), t, [4*pi 6*pi], '-.*c')

Plot 3-D parametric curve - MATLAB fplot3 (3)

Plot 3-D Parametric Line Using Symbolic Functions

Open Live Script

Plot the 3-D parametric line

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

syms x(t) y(t) z(t)x(t) = sin(t);y(t) = cos(t);z(t) = cos(2*t);fplot3(x,y,z)

Plot 3-D parametric curve - MATLAB fplot3 (4)

Plot Multiple Lines on Same Figure

Open Live Script

Plot multiple lines either by passing the inputs as a vector or by using hold on to successively plot on the same figure. If you specify LineSpec and Name-Value arguments, they apply to all lines. To set options for individual lines, use the function handles returned by fplot3.

Divide a figure into two subplots using subplot. On the first subplot, plot two parameterized lines using vector input. On the second subplot, plot the same lines using hold on.

syms tsubplot(2,1,1)fplot3([t -t], t, [t -t])title('Multiple Lines Using Vector Inputs')subplot(2,1,2)fplot3(t, t, t)hold onfplot3(-t, t, -t)title('Multiple Lines Using Hold On Command')hold off

Plot 3-D parametric curve - MATLAB fplot3 (5)

Modify 3-D Parametric Line After Creation

Open Live Script

Plot the parametric line

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

Provide an output to make fplot return the plot object.

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

Plot 3-D parametric curve - MATLAB fplot3 (6)

fp = ParameterizedFunctionLine with properties: XFunction: exp(-abs(t)/10)*sin(5*abs(t)) YFunction: exp(-abs(t)/10)*cos(5*abs(t)) ZFunction: t Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Use GET to show all properties

Change the range of parameter values to [-10 10] and the line color to red by using the TRange and Color properties of fp respectively.

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

Plot 3-D parametric curve - MATLAB fplot3 (7)

Add Title and Axis Labels and Format Ticks

Open Live Script

For t values in the range -2π to 2π, plot the parametric line

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

Add a title and axis labels. Create the x-axis ticks by spanning the x-axis limits at intervals of pi/2. Display these ticks by using the XTick property. Create x-axis labels by using arrayfun to apply texlabel to S. Display these labels by using the XTickLabel property. Repeat these steps for the y-axis.

To use LaTeX in plots, see latex.

syms txt = t;yt = t/2;zt = sin(6*t);fplot3(xt,yt,zt,[-2*pi 2*pi],'MeshDensity',30)view(52.5,30)xlabel('x')ylabel('y')title('x=t, y=t/2, z=sin(6t) for -2\pi < t < 2\pi')ax = gca;S = sym(ax.XLim(1):pi/2:ax.XLim(2));ax.XTick = double(S);ax.XTickLabel = arrayfun(@texlabel, S, 'UniformOutput', false);S = sym(ax.YLim(1):pi/2:ax.YLim(2));ax.YTick = double(S);ax.YTickLabel = arrayfun(@texlabel, S, 'UniformOutput', false);

Plot 3-D parametric curve - MATLAB fplot3 (8)

Create Animation of Parametric Curve

Open Script

Create an animation by changing the displayed expression using the XFunction, YFunction, and ZFunction properties, and then use drawnow to update the plot. To export to GIF, see imwrite.

By varying the variable Plot 3-D parametric curve - MATLAB fplot3 (9) from Plot 3-D parametric curve - MATLAB fplot3 (10) to Plot 3-D parametric curve - MATLAB fplot3 (11), animate the parametric curve

Plot 3-D parametric curve - MATLAB fplot3 (12)

Plot 3-D parametric curve - MATLAB fplot3 (13)

Plot 3-D parametric curve - MATLAB fplot3 (14)

syms tfp = fplot3(t+sin(40*t),-t+cos(40*t), sin(t));for i=0:pi/10:4*pi fp.ZFunction = sin(t+i); drawnowend

Plot 3-D parametric curve - MATLAB fplot3 (15)

Input Arguments

collapse all

xtParametric input for x-axis
symbolic expression | symbolic function

Parametric input for x-axis, specified as a symbolic expressionor function. fplot3 uses symvar tofind the parameter.

ytParametric input for y-axis
symbolic expression | symbolic function

Parametric input for y-axis, specified as a symbolic expressionor function. fplot3 uses symvar tofind the parameter.

ztParametric input for z-axis
symbolic expression | symbolic function

Parametric input for z-axis, specified as a symbolic expressionor function. fplot3 uses symvar tofind the parameter.

[tmin tmax]Range of values of parameter
[–5 5] (default) | vector of two numbers

Range of values of parameter, specified as a vector of two numbers.The default range is [-5 5].

axAxes object
axes object

Axes object. If you do not specify an axes object, then fplot3 usesthe current axes.

LineSpecLine style, marker, and color
string scalar | character vector

Line style, marker, and color, specified as a string scalar or character vector 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.

Example: "--or" is a red dashed line with circle markers.

Line StyleDescriptionResulting Line
"-"Solid line

Plot 3-D parametric curve - MATLAB fplot3 (16)

"--"Dashed line

Plot 3-D parametric curve - MATLAB fplot3 (17)

":"Dotted line

Plot 3-D parametric curve - MATLAB fplot3 (18)

"-."Dash-dotted line

Plot 3-D parametric curve - MATLAB fplot3 (19)

MarkerDescriptionResulting Marker
"o"Circle

Plot 3-D parametric curve - MATLAB fplot3 (20)

"+"Plus sign

Plot 3-D parametric curve - MATLAB fplot3 (21)

"*"Asterisk

Plot 3-D parametric curve - MATLAB fplot3 (22)

"."Point

Plot 3-D parametric curve - MATLAB fplot3 (23)

"x"Cross

Plot 3-D parametric curve - MATLAB fplot3 (24)

"_"Horizontal line

Plot 3-D parametric curve - MATLAB fplot3 (25)

"|"Vertical line

Plot 3-D parametric curve - MATLAB fplot3 (26)

"square"Square

Plot 3-D parametric curve - MATLAB fplot3 (27)

"diamond"Diamond

Plot 3-D parametric curve - MATLAB fplot3 (28)

"^"Upward-pointing triangle

Plot 3-D parametric curve - MATLAB fplot3 (29)

"v"Downward-pointing triangle

Plot 3-D parametric curve - MATLAB fplot3 (30)

">"Right-pointing triangle

Plot 3-D parametric curve - MATLAB fplot3 (31)

"<"Left-pointing triangle

Plot 3-D parametric curve - MATLAB fplot3 (32)

"pentagram"Pentagram

Plot 3-D parametric curve - MATLAB fplot3 (33)

"hexagram"Hexagram

Plot 3-D parametric curve - MATLAB fplot3 (34)

Color NameShort NameRGB TripletAppearance
"red""r"[1 0 0]

Plot 3-D parametric curve - MATLAB fplot3 (35)

"green""g"[0 1 0]

Plot 3-D parametric curve - MATLAB fplot3 (36)

"blue""b"[0 0 1]

Plot 3-D parametric curve - MATLAB fplot3 (37)

"cyan" "c"[0 1 1]

Plot 3-D parametric curve - MATLAB fplot3 (38)

"magenta""m"[1 0 1]

Plot 3-D parametric curve - MATLAB fplot3 (39)

"yellow""y"[1 1 0]

Plot 3-D parametric curve - MATLAB fplot3 (40)

"black""k"[0 0 0]

Plot 3-D parametric curve - MATLAB fplot3 (41)

"white""w"[1 1 1]

Plot 3-D parametric curve - MATLAB fplot3 (42)

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'Marker','o','MarkerFaceColor','red'

The properties listed here are only a subset. For a completelist, see ParameterizedFunctionLine Properties.

Output Arguments

collapse all

fp — One or more parameterized function line objects
scalar | vector

One or more parameterized line objects, returned as a scalaror a vector. You can use these objects to query and modify propertiesof a specific parameterized line. For details, see ParameterizedFunctionLine Properties.

Version History

Introduced in R2016a

See Also

Functions

  • fcontour | fimplicit | fimplicit3 | fmesh | fplot | fpolarplot | fsurf

Properties

  • ParameterizedFunctionLine Properties

Topics

  • Create Plots of Symbolic Expressions

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Plot 3-D parametric curve - MATLAB fplot3 (43)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Plot 3-D parametric curve - MATLAB fplot3 (2024)

FAQs

How to plot 3-D parametric equations in Matlab? ›

To plot vector functions or parametric equations, you follow the same idea as in plotting 2D functions, setting up your domain for t. Then you establish x, y (and z if applicable) according to the equations, then plot using the plot(x,y) for 2D or the plot3(x,y,z) for 3D command.

How to plot parametric plot in Matlab? ›

Plot Multiple Lines on Same Figure

To set options for individual lines, use the function handles returned by fplot3 . Divide a figure into two subplots using subplot . On the first subplot, plot two parameterized lines using vector input. On the second subplot, plot the same lines using hold on .

How do you find the parametric equation of a curve in 3-D? ›

A 3-D curve can be given parametrically by x = f(t), y = g(t) and z = h(t) where t is on some interval I and f, g, and h are all continuous on I. We could specify the curve by the position vector .

How do you plot parametric equations? ›

To plot a parametric curve, simply create an ordered pair where one or both coordinates are defined in terms of the parameter t. By default, parametric curves are plotted for values of t in the interval [0, 1], but it is possible to adjust the domain manually using the inputs beneath the expression.

What is the parametric equation of a 3-D line? ›

Parametric Equation of a Line in 3D

These equations x=x0+at, y=y0+bt and z=z0+ct are called the parametric equations of the line that contains the point (x0,y0,z0) and has the direction vector →V=aˆi+bˆj+cˆk.

What is the function of fplot3? ›

fplot3(___, Name,Value ) specifies line properties using one or more name-value pair arguments. For example, 'LineWidth',2 specifies a line width of 2 points. fplot3( ax ,___) plots into the axes specified by ax instead of the current axes. Specify the axes as the first input argument.

How do you make a good plot in MATLAB? ›

Direct link to this comment
  1. Increase the linewidth (2 or 3 is good).
  2. Add a grid.
  3. Add minor ticks to the axes.
  4. Plot as an area with solid line and semi-transparent fill.
  5. Set the axes limits appropriately.
  6. Add a legend.
  7. Change the font and fontsize to match the output size.
  8. Set the figure aspect ratio correctly.
Feb 27, 2016

How do you graph parametric mode? ›

As shown above, any function y = f(x) can be graphed in Parametric mode by letting x = t and y = f(t). The inverse of a function can be created by swapping the values of x and y. That is, the inverse of y = f(x) is found by letting x = f(t) and y = t.

How to plot a 3-D graph? ›

  1. Define a matrix with three columns using the random function.
  2. Plot the matrix and change the Trace Color.
  3. Define a vector-valued function of a single parameter to create a curve in 3D.

How to make a 3-D array in MATLAB? ›

You can create a multidimensional array by creating a 2-D matrix first, and then extending it. For example, first define a 3-by-3 matrix as the first page in a 3-D array. Now add a second page. To do this, assign another 3-by-3 matrix to the index value 2 in the third dimension.

How to plot a 3-D graph in MATLAB using Excel data? ›

Please follow the following steps:
  1. Prepare Your Excel File: Ensure your Excel file is organized such that it represents a grid of Z values. ...
  2. Read Data from Excel File: Use the readmatrix function to read the data from the Excel file into MATLAB.
  3. Extract X, Y, and Z Data: ...
  4. Plot the Surface:
Jun 26, 2024

What is the formula for a parametric curve? ›

The derivative of the parametrically defined curve x=x(t) and y=y(t) can be calculated using the formula dydx=y′(t)x′(t). Using the derivative, we can find the equation of a tangent line to a parametric curve. The area between a parametric curve and the x-axis can be determined by using the formula A=∫t2t1y(t)x′(t)dt.

How do you convert to parametric curve? ›

Converting from rectangular to parametric can be very simple: given y=f(x), the parametric equations x=t, y=f(t) produce the same graph. As an example, given y=x2, the parametric equations x=t, y=t2 produce the familiar parabola. However, other parametrizations can be used.

How to plot 3-D cylinder in MATLAB? ›

To draw the cylinder, pass X , Y , and Z to the surf or mesh function. [X,Y,Z] = cylinder( r ) returns the x-, y-, and z- coordinates of a cylinder with the specified profile curve, r , and 20 equally spaced points around its circumference.

What are the parametric equations for 3-D surfaces? ›

The equations , x = x ( s , t ) , , y = y ( s , t ) , and z = z ( s , t ) are the parametric equations for the surface, or a parametrization of the surface.

References

Top Articles
Latest Posts
Article information

Author: Laurine Ryan

Last Updated:

Views: 5419

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Laurine Ryan

Birthday: 1994-12-23

Address: Suite 751 871 Lissette Throughway, West Kittie, NH 41603

Phone: +2366831109631

Job: Sales Producer

Hobby: Creative writing, Motor sports, Do it yourself, Skateboarding, Coffee roasting, Calligraphy, Stand-up comedy

Introduction: My name is Laurine Ryan, I am a adorable, fair, graceful, spotless, gorgeous, homely, cooperative person who loves writing and wants to share my knowledge and understanding with you.