Automatically update plots in GUI

I would like to automatically update a grid plot over an image. Right now I am taking data from GUI edit text boxes labeled "Horizontal Lines" and "Vertical Lines." The numbers in these boxes plot the lines once a button is pushed, but I would like for the plot to change automatically without a pushbutton (i.e. I can change automatically from a 3X3 grid to a 4X4 grid just by typing, not by hitting a push button). I would also like to avoid using a while loop. Also I need to keep the image behind the grid intact. Here is some relevant code:
axes(handles.imageplot);
hold on
c=[0 0 0;0 0 1;0 1 0; 0 1 1;1 0 0;1 0 1;1 1 0;0 0.75 0.75;0 0.5 0;0.75 0.75 0;... 1 0.50 0.25;0.75 0 0.75;0.7 0.7 0.7;0.8 0.7 0.6;0.6 0.5 0.5;1 1 0.25];
mm=1;
for k=X/(m+1):X/(m+1):X-(X/(m+1))
mm=mm+1;
x=[1,Y];
y=[k,k];
plot(x,y,'color',c(mm,:));
end
%vertical
mm=1;
for k=Y/(n+1):Y/(n+1):Y-(Y/(n+1));
mm=mm+1;
x=[k,k];
y=[1,X];
plot(x,y,'color',c(mm,:));
end
hold off
Any help is appreciated.

 채택된 답변

Evan
Evan 2013년 6월 18일
편집: Evan 2013년 6월 18일

0 개 추천

So you want your axes to update whenever data is typed into your editboxes? If so, wouldn't you just put the relevant code into the callback of the editbox instead of the pushbutton?
Sorry if I'm not understanding.

댓글 수: 2

Paul
Paul 2013년 6월 18일
Well...I'm kind of a doofus. Haha, that worked well, thanks!
Evan
Evan 2013년 6월 18일
No worries, haha. Trust me, I've asked way sillier questions than this on this site. :P

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Shashank Prasanna
Shashank Prasanna 2013년 6월 18일

0 개 추천

You can define a callback for edit uicontrol:
and have the gui updated once the user clicks outside or hits enter.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2013년 6월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by