Line Plots of 3-D Data
Basic 3-D Plotting: The plot3 function
The 3-D analog of the plot function is plot3. If x, y,
and z are three vectors of the same length,
plot3(x,y,z)
generates a line in 3-D through the points whose coordinates
are the elements of x, y, and z and
then produces a 2-D projection of that line on the screen. For example,
these statements produce a helix:
t = 0:pi/50:10*pi;
plot3(sin(t),cos(t),t)
axis square; grid on

Back to Top
Plotting Matrix Data
If the arguments to plot3 are matrices of the same size, lines obtained
from the columns of X, Y, and Z are
plotted. For example:
[X,Y] = meshgrid([-2:0.1:2]);
Z = X.*exp(-X.^2-Y.^2);
plot3(X,Y,Z)
grid on

Notice how line colors cycle, based on the axes ColorOrder property.
Back to Top
 | Typical 3-D Graph | | Representing a Matrix as a Surface |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit