From: Amalekster Amalek on
Hi,

I am trying to animate a set of tracked coordinates (NOT in real time). Say, my input file has a million coordinates and I want to show them as moving (or progressing) in time in a 2D plot.

The code I am using now, based on an example from the Matlab documentation follows:
-----------------------------
frame = 10;

dx = dm(1:frame, 1);
dy = dm(1:frame, 2);
h = plot(dx, dy);

for i=frame+1:1000000
dx = dm(i:i+frame, 1);
dy = dm(i:i+frame, 2);
set(h,'XData', dx);
set(h,'YData', dy);
drawnow
end;
-----------------------------
The main data matrix, dm, contains 1M pairs of coordinates, and so all of the file input had been completed before the plotting starts.

The data points are transferred into the temporary X, Y arrays (dx and dy) and these are plotted (in h = plot(dx, dy);). Thereafter, I update dx and dy and then set the data sources in set(h, 'XData', dx) etc., and then drawnow.

But as most of you would know, drawnow slows the process incredibly. The alternative method to set XDataSource and YDataSource and use refreshdata is even slower, but these are the only methods suggested in the Matlab documentation.

Any ideas on how to speed this up would be very much appreciated (obviously, I already tried just using plot() repeatedly. This brings Matlab to its knees in about 50K iterations).

Thanks!

PS: My apologies if this question or similar has been answered. I searched diligently and was unable to find any useful alternatives so far.
 | 
Pages: 1
Prev: resize array
Next: resize array