How to Plot a Line in 3D Matlab


Many scientists and engineers use Matlab, a software application developed by Mathworks, to analyze small and large numerical data sets. They then visualize them onscreen using, for example, scatter, line and contour plots, with Matlab's extensive graphing functions. In addition to plotting numerical data, scientists and engineers use Matlab to plot equations. If you have a line described by three variables, you may need to plot it in three dimensions to help you understand the equation more thoroughly.

  • Type "z = 0:(pi/100):(20*pi)" in the command window to generate a series of points along the z-axis.

  • Type "x = cos(z)" to calculate the position of each z value on the x-axis.

  • Type "y = sin(z)" to calculate the position of each z value on the y-axis.

  • Type "plot3(x,y,z)" to plot each of the points as a line -- a 3-D helix -- on a 3-D plot..

  • Type "xlabel('cos(z)'), ylabel('sin(z)'), zlabel('z')" to label the axes.

  • Type "grid on" to show grid lines.

Tips & Warnings

  • You can change the appearance of the line using the "linespec" line specification string syntax. Add the linespec string to the end of the plot3 function arguments. For example, type "plot3(x,y,z,'--or)" to plot a dashed line with circles at each point and color both the line and markers red. Refer to the linespec documentation for all the different styles available.

Related Searches


  • Photo Credit Jupiterimages/ Images
Promoted By Zergnet


Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!