필터 지우기
필터 지우기

Start & stop opeartions using single push button

조회 수: 2 (최근 30일)
shaz
shaz 2012년 12월 6일
i need to plot values from 1:100 like plot(1:100) only when i press the push button .
like i will press push button & plot only first 50 values then i will stop using the same push button & again start for plotting remaining 50 values
thanks in advance
  댓글 수: 1
Jan
Jan 2012년 12월 10일
What have you tried so far and which problems occurred? How can we assist you to solve your problem?

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

답변 (1개)

Ryan G
Ryan G 2012년 12월 6일
You could set a flag when you hit start, for example
isRunning = 1;
setappdata(handles.myPushbutton,'isRunning',isRunning);
and also change the text of the pushbutton to stop
set(handles.myPushbutton,'String','Stop');
Finally you could implement a timer object to easily implement the start/stop functionality of the plot.
So the final callback would be something like:
isRunning = getappdata(hObject,'isRunning')
if isRunning
stop(myTimerObject);
isRunning = 0;
setappdata(hObject,'isRunning',isRunning);
else
%setup and start timer
isRunning = 1;
setappdata(hObject,'isRunning',isRunning);
end
In fact you don't really need the isRunning variable as you can find that out directly from the timer object. I'm just to lazy to redo this post.
  댓글 수: 2
shaz
shaz 2012년 12월 10일
편집: shaz 2012년 12월 10일
sorry ...i need a single push button performing both start & stop actions
start means plotting values & stop means stop plotting the values
Start(1st press)-----plot values-->stop(2nd press)---stop plotting values---->Start(3rd press)----continue plotting again from where it was left till data is available
Ryan G
Ryan G 2012년 12월 10일
What I described does that. You would have to define what goes in each section of the code to start/stop/create the timer.

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

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by