As a continuation to one of my previous posts, on multi-line comet plots, this submission extends comet3 to give the user ability to control the length of the tail, the speed of the animation, and the style of the head and tail of the comet. comet and comet3 are useful functions, because these are functions that take similar type of input as other plotting functions and have animation built into them. I have used both of these functions in the past, but as computers became faster, the animation became too fast to view. That's why I really like the ability of PlotComet_3D to control the speed.
Here's what comet3 looks like.
t = -pi:pi/300:pi; x = sin(5*t); y = cos(3*t); z = t;
comet3(x, y, z)
By using Nick's PlotComet_3D, you can specify the speed in frequency, allowing for a consistent animation regardless of processing speed. Here, I'm also specifying a particular marker for the head of the comet.
% Define marker style for the head of the comet Head = struct(... 'Marker', 'p', ... 'MarkerSize', 10, ... 'MarkerEdgeColor', 'b', ... 'MarkerFaceColor', 'b');
% Animate at 100 Hz, tail length of 30 PlotComet_3D(x, y, z, ... 'Frequency', 100, ... 'blockSize', 30, ... 'headFormat', Head);
Get the MATLAB code
Published with MATLAB® R2013b
Comments are closed.