Updating Plot "On the Fly" with MATLAB

  • Context: MATLAB 
  • Thread starter Thread starter Euclid
  • Start date Start date
  • Tags Tags
    Matlab Plot
Click For Summary
SUMMARY

The discussion focuses on updating plots "on the fly" in MATLAB, specifically using a function that modifies pixel values in a 100x100 matrix. The user initially attempts to use the "figure" command before the "image" function but ends up generating multiple images instead of a single updated plot. The solution found is the "drawnow" function, which updates the plot but is criticized for its slow performance, as it redraws the entire plot rather than just the modified pixels. The user expresses the need for a more efficient method to update only the changed portions of the image.

PREREQUISITES
  • Familiarity with MATLAB programming and syntax
  • Understanding of image processing concepts in MATLAB
  • Knowledge of matrix manipulation in MATLAB
  • Experience with MATLAB plotting functions such as "image" and "colormap"
NEXT STEPS
  • Research MATLAB's "set" function for updating specific plot properties
  • Explore MATLAB's "update" and "refreshdata" functions for dynamic plotting
  • Investigate custom functions for partial image updates in MATLAB
  • Learn about performance optimization techniques in MATLAB graphics rendering
USEFUL FOR

MATLAB developers, data visualizers, and researchers looking to enhance real-time plotting capabilities in their applications.

Euclid
Messages
213
Reaction score
0
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
x(i,j)=uint8(255^((i+j)/200));
image(x); colormap(gray)
end
end
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:
Physics news on Phys.org
This is not an easy task, and there is (to the best of my knowledge) no inbuilt function for this. You are asking for a function that will find the portion of the image that has been changed/updated, and change only that portion. I doubt whether something like that actually exists. I have seen Matlab redraw the plots/figures rather than change portions, not update previous plots. Maybe this can be communicated to the developers.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K