MATLAB: Dynamic plot of a co-ordinates matrix as it is updated

393 views Asked by At

I am writing a MATLAB code to plot an x-y coordinate matrix. The matrix is constantly updated(as fast as micro or milliseconds) by obtaining raw data from an external device. I need to update the plot as and when the matrix changes. Essentially my requirement is to generate something like a video of how the matrix evolves, by plotting it.

This is a piece of code I tried:

(b is the 2D matrix which is constantly updated)

while(<condition>) 
            b(i,1)=<x-coordinate>      %obtained as raw data from external device
            b(i,2)=<y-coordinate>      %obtained as raw data from external device
            scatter(b(:,1),b(:,2));
end

The problem here is that the b matrix receives values at such a fast rate that, the scatter() function lags while plotting.

How do I get a smooth dynamic plot of the constantly updated matrix?

Thanks!

0

There are 0 answers