MATLAB: How to zoom in on the tail of a 2-D comet plot when using COMET in MATLAB 7.14 (R2012a)

cometdisappearMATLABzoom

When I use the COMET function, then try to zoom in on a section of the plot, the plot data seems to disappear.

Best Answer

The ability to zoom in on the tail of a 2-D comet plot when using function COMET is currently not available in MATLAB 7.14 (R2012a). This is an expected behavior in the way function COMET is designed and implemented.
Why COMET behaves this way
-----------------------------------------
Referring to the source code of COMET, line 49, you can see that the line object 'tail' has its 'Erase' property set to 'none'. On line 80, the 'XData' and 'YData' of the line object 'tail' are iteratively overwritten. Taken together, these two lines of code tell us that COMET leaves an ephemeral trail along the path that a short line segment travels. Having the 'Erase' property set to 'none' allows us to see the trail despite the fact that the only line object that exists in the figure is the last instance of 'tail'. You can verify this by zooming in on the point where the curve terminates. Please refer to the following for more on the 'Erase' property of line objects:
A Sketch of persistentComet
--------------------------------------
To be able to zoom in anywhere along the curve drawn by the COMET function,you need to make the following changes. First, the 'Erase' property of the 'body' and 'tail' line objects should be changed to 'normal', which is the default value for this property. Next, wherever the 'XData' and 'YData' of 'body' and 'tail' are updated, you should have the two data vectors contain all of the points along the curve that exist up to each stage of the animation. For example, line 71 should be changed to
71- set(body,'xdata',x(1:j),'ydata',y(1:j))
where all points of 'x' and 'y' up to index 'j' are now included.
Please find attached at the bottom this page, the augmented form of COMET in a MATLAB-file called ‘persistentComet.m’ along with an example script called ‘example_persistentComet.m’.