matlabplotmovie

Plotting to movie with given X, Y and Time-Stamp T in matLab


I have three arrays X, Y, T of same size where X and Y are position of moving points and T is time-stamp for these coordinates.

I want to plot movie of position of points on respective co-ordinates.

For example if X = {1, 2, 3, 4, 4,...}, Y = {1, 2, 2, 3, 3,...} and T = {1.1, 2, 2.2, 2.6, 3,...} this mean the object is at (1, 1) on 1.1 sec, at (2,2) on 2 second, at (3, 2) on 2.2 second etc.

I want to moving plot of point on the given time.

I tried using 'pause' but it uses uniform pause time for all points and given time-stamp can not be used with this.


Solution

  • Try using pause(n) instead of pause.

    Pause(n), where n is a real number, will pause for the specified number of seconds. Accuracy is limited by the operating system. For example, here are the timing results of 4 identical calls to pause:

    >> tic;pause(1.4);toc
    Elapsed time is 1.402366 seconds.
    >> tic;pause(1.4);toc
    Elapsed time is 1.400186 seconds.
    >> tic;pause(1.4);toc
    Elapsed time is 1.405679 seconds.
    >> tic;pause(1.4);toc
    Elapsed time is 1.401285 seconds.
    

    Alternatively, if you desire a smooth frame rate, you could interpolate the data between two successive time points using the interp2 command, and have the figure updated at a constant interval.