How to append to plot, or continuously update plot? plot3d? plot3?

Discussion in 'MATLAB' started by Kamil, Jul 30, 2009.

  1. Kamil

    Kamil Guest


    I am trying to use matlab for "real time" processing and display.

    I would like to update a plot with new data and have that data be
    appended to a plot.

    This will be a 3d plot using plot3 command. A constant X axis will be
    defined for this figure and I would like to plot until the X axis is
    completely filled up. 8 lines will be drawn on this plot.

    This was my plan...
    1) initialize the plot with some initial data. Also set the X axis to
    the maximum length desired.
    2) Update the plot
    2.1) get current data on plot using get(h, 'Xdata')
    2.2) make a new variable the length of oldXdata and newXdata.
    2.3) concat oldXdata with newXdata
    2.4) redraw

    is there a simpler way to do this? I am getting lost because the
    Xdata for a plot3d is a cell array and im having trouble combining the
    newXdata with the oldXdata.

    Any help would be appreciated,

    Kamil, Jul 30, 2009
    1. Advertisements

  2. Have you tried plotting in a loop and using the 'hold on' command?
    Dave Brackett, Jul 31, 2009
    1. Advertisements

  3. hi Dave,
    I tried using hold on, but the figure is not shown in real-time. It is AFTER all the plots are made.
    dances_with_wolves N G, Aug 2, 2009
  4. Kamil

    Bruno Luong Guest

    Du you call GET with array of handle ? Fort single handle it returns double array.

    Show important snips of your code.

    You could also initialize your plots with NaN array having a maximum size, and fill progressively the tail NaN with real data. This might accelerate slightly the updating.

    Bruno Luong, Aug 2, 2009
  5. Kamil

    Bruno Luong Guest

    Use commands DRAWNOW or REFRESH to force the plot.

    Bruno Luong, Aug 2, 2009
  6. Kamil

    Richard Guest

    with loop. For 2D data, "comet" plots in real time. For 3D data, no

    Richard, Aug 2, 2009
  7. try pause in while(1) loop
    update data
    Naveen Cherala, Apr 8, 2010
  8. Hello Kamil,

    Can you tell us the solution?
    How did you accomplish it?
    I'd like to do the same but i'm missing some important steps apparenly.

    Kind Regards,
    Kristof Lieben, Dec 27, 2011
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.