Some basic "issues"...
- Your figure line is figure(6) which always reverts to the same figure you requested so it's not surprising it's always plotting on the same figure--you gave it no choice.
- Which iteration loop is the one? Place a figure statement first thing after the beginning of that loop to create a new figure. Then create the new axes to plot into and set the parameters for it such as the 'XDir' parameter.
- plot is high-level function that resets much of the behind the scenes preliminaries for plotting...hold on bypasses a bunch of that but once you set it, you immediately turn it back off, losing the effect every iteration. "Don't do that!" when you want to continue to add to an existing plot; that's what it's for.
More efficient by far for such "realtime" plotting is to update the 'X|YData' properties directly as discussed and illustrated in the documentation for graphics under the heading of Animation in the section on 2D graphics. Several alternatives are given with examples..
Best Answer