Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Plotting in matlab

  1. Sep 13, 2007 #1
    I am trying to write a function that will update a plot "on the fly". For instance, in the test function:
    function colorplot
    x = ones(100,100);
    for i = 1:100
    for j = 1:100
    image(x); colormap(gray)
    MATLAB will run the entire function before displaying the image in the matrix x. I want to get MATLAB to update the plot as soon as it changes a single pixel (or more generally, whenever I tell it to!). Does anyone know how to do this? The only way I have been able to close to getting this to happen is to use the "figure" command right before "image", but this just generates 100*100 images when I only want 1.

    UPDATE: I found a function drawnow which performs what I want the plot to do, but it is extremely slow. drawnow redraws the whole plot but I am only updating a few pixels. Any ideas?
    Last edited: Sep 13, 2007
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you help with the solution or looking for help too?
Draft saved Draft deleted

Similar Discussions: Plotting in matlab
  1. Plotting in Matlab (Replies: 2)

  2. MATLAB plots (Replies: 1)

  3. Matlab Plot (Replies: 2)

  4. Plotting in MATLAB (Replies: 8)

  5. Plotting with MATLAB (Replies: 1)