plot3Define
tas a vector of values between 0 and 10π. Definestandctas vectors of sine and cosine values. Then plotst,ct, andt.
t = 0:pi/50:10*pi; st = sin(t); ct = cos(t); plot3(st,ct,t) fig2plotly()
Create two sets of x-, y-, and z-coordinates.
t = 0:pi/500:pi; xt1 = sin(t).*cos(10*t); yt1 = sin(t).*sin(10*t); zt1 = cos(t); xt2 = sin(t).*cos(12*t); yt2 = sin(t).*sin(12*t); zt2 = cos(t);
Call the
plot3function, and specify consecutiveXYZtriplets.
plot3(xt1,yt1,zt1,xt2,yt2,zt2) fig2plotly()
Create matrix
Xcontaining three rows of x-coordinates. Create matrixYcontaining three rows of y-coordinates.
t = 0:pi/500:pi; X(1,:) = sin(t).*cos(10*t); X(2,:) = sin(t).*cos(12*t); X(3,:) = sin(t).*cos(20*t); Y(1,:) = sin(t).*sin(10*t); Y(2,:) = sin(t).*sin(12*t); Y(3,:) = sin(t).*sin(20*t);
Create matrix
Zcontaining the z-coordinates for all three sets.
Z = cos(t);
Plot all three sets of coordinates on the same set of axes.
plot3(X,Y,Z) fig2plotly()
Create vectors
xt,yt, andzt.
t = 0:pi/500:40*pi; xt = (3 + cos(sqrt(32)*t)).*cos(t); yt = sin(sqrt(32) * t); zt = (3 + cos(sqrt(32)*t)).*sin(t);
Plot the data, and use the
axis equalcommand to space the tick units equally along each axis. Then specify the labels for each axis.
plot3(xt,yt,zt)
axis equal
xlabel('x(t)')
ylabel('y(t)')
zlabel('z(t)')
fig2plotly()
Create vectors
t,xt, andyt, and plot the points in those vectors using circular markers.
t = 0:pi/20:10*pi; xt = sin(t); yt = cos(t); plot3(xt,yt,t,'o') fig2plotly()
Create vectors
t,xt, andyt, and plot the points in those vectors as a blue line with 10-point circular markers. Use a hexadecimal color code to specify a light blue fill color for the markers.
t = 0:pi/20:10*pi; xt = sin(t); yt = cos(t); plot3(xt,yt,t,'-o','Color','b','MarkerSize',10,'MarkerFaceColor','#D9FFFF') fig2plotly()
Create vector
t. Then usetto calculate two sets of x and y values.
t = 0:pi/20:10*pi; xt1 = sin(t); yt1 = cos(t); xt2 = sin(2*t); yt2 = cos(2*t);
Plot the two sets of values. Use the default line for the first set, and specify a dashed line for the second set.
plot3(xt1,yt1,t,xt2,yt2,t,'--') fig2plotly()
Create vectors
t,xt, andyt, and plot the data in those vectors. Return the chart line in the output variablep.
t = linspace(-10,10,1000); xt = exp(-t./10).*sin(5*t); yt = exp(-t./10).*cos(5*t); p = plot3(xt,yt,t); fig2plotly()
Change the line width to
3.
p.LineWidth = 3; fig2plotly()
Starting in R2019b, you can display a tiling of plots using the
tiledlayoutandnexttilefunctions. Call thetiledlayoutfunction to create a 1-by-2 tiled chart layout. Call thenexttilefunction to create the axes objectsax1andax2. Create separate line plots in the axes by specifying the axes object as the first argument toplot3.
tiledlayout(1,2) % Left plot ax1 = nexttile; t = 0:pi/20:10*pi; xt1 = sin(t); yt1 = cos(t); plot3(ax1,xt1,yt1,t) title(ax1,'Helix With 5 Turns') % Right plot ax2 = nexttile; t = 0:pi/20:10*pi; xt2 = sin(2*t); yt2 = cos(2*t); plot3(ax2,xt2,yt2,t) title(ax2,'Helix With 10 Turns') fig2plotly()
Create
xandyas vectors of random values between0and1. Createzas a vector of random duration values.
x = rand(1,10); y = rand(1,10); z = duration(rand(10,1),randi(60,10,1),randi(60,10,1));
Plot
x,y, andz, and specify the format for the z-axis as minutes and seconds. Then add axis labels, and turn on the grid to make it easier to visualize the points within the plot box.
plot3(x,y,z,'o','DurationTickFormat','mm:ss')
xlabel('X')
ylabel('Y')
zlabel('Duration')
grid on
fig2plotly()
Create vectors
xt,yt, andzt. Plot the values, specifying a solid line with circular markers using theLineSpecargument. Specify theMarkerIndicesproperty to place one marker at the 200th data point.
t = 0:pi/500:pi; xt(1,:) = sin(t).*cos(10*t); yt(1,:) = sin(t).*sin(10*t); zt = cos(t); plot3(xt,yt,zt,'-o','MarkerIndices',200) fig2plotly()