3D Graphics:  Multiple plots

One way to plot multiple plots is to hold on and plot as many additional plots as needed.  Another easier is to plot Matrices.  Each column in a Matrix will create a different line/curve.  Such a plot command also returns a vector of handles so that each of the plot can be customized.  The following examples creates two plots using matrices, changes the second one to be dashed, and traces each particle along their path.

MATLAB Code
% 3D Graphics - several line plots (using Matrices)
% Dr. P.Venkataraman
% The path traced by a particle in 3D space

format compact
'NumberTitle','off','Position',[10,350,400,300]);
t = 0:0.1:3;
title('\bf\itMultiple plots using Matrices','Color','k', ...
'VerticalAlignment','bottom')
% create plots
x = 2*sin(2*t);
y1 = 3*cos(2*t);
y2 = 2*exp(0.3*t);
z1 = t;
z2 = 1 + 0.5*t.*t;
h = plot3([x' x'],[y1' y2'],[z1' z2'], ...  % 2 column matrices
'LineWidth',2);
set(h(2),'LineStyle','--');  % set property for second plot
hold on
for i=1:length(t)
if i> 1
delete(h2); % deletes the marker
delete(h3); % delete the line
end
h2 = plot3(x(i),y1(i),z1(i),'bo','MarkerFaceColor','r'); % creates a marker
h3 = plot3(x(i),y2(i),z2(i),'ms','MarkerFaceColor','y'); % creates a marker
pause(0.1) % pauses the plot or you can't see the animation
end
hold off
ylabel('y', ...
'FontWeight','b','Color','b', ...
'VerticalAlignment','bottom');  % boldface blue
xlabel('x', ...
'FontWeight','b','Color','b', ...
'VerticalAlignment','bottom');  % boldface blue
zlabel('z', ...
'FontWeight','b','Color','b', ...
'VerticalAlignment','bottom');  % boldface blue
title('\bf\itMultiple plots using Matrices','Color','k', ...
'VerticalAlignment','bottom')
grid