File Exchange Pick of the Week

Our best user submissions

Comet3 with Speed Control

Jiro's pick this week is 3D Comet Plot by Nick.

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);

Comments

If you have used comet or comet3 in the past and stopped using it because the animation has gotten too fast, give this a try. Let us know what you think here or leave a comment for Nick.




Published with MATLAB® R2013b

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.