MATLAB: How could I update the imshow

imshowmatlab gui

Hi,all,
I have a GUI which receive the data through the serial port continuously. And I want to use these data to show the location trace in the picture using imshow.
Afterwards I realize the memory is reduced bacause I continuing creat a new image in the same axes.
So I would like to know how can I updating the imshow rather than creating a new image.
ditu =imread('google.bmp');
[M,N]=size(ditu(:,:,1))
ditu((M-y-1):(M-y+1),((x-1):(x+1)),1)=255;
ditu((M-y-1):(M-y+1),((x-1):(x+1)),2)=0;
ditu((M-y-1):(M-y+1),((x-1):(x+1)),3)=0;
imshow(ditu, 'Parent', handles.axes1);
Thank you,
Shaofan

Best Answer

Calling imshow() multiple times will put multiple images into your axes. To avoid that and keep just one image at a time in there, use cla or cla reset
axes(handles.axes1);
cla reset;
imshow(ditu, 'Parent', handles.axes1);