For and Break ; in Guide

조회 수: 1 (최근 30일)
nsbd
nsbd 2011년 5월 8일
Hi all, Get out of the loop "for" for guide
"
---------------------------------------------------------------------
K=handles.b
function pushbutton2_Callback(hObject, eventdata, handles)
for i=1:n;
%event
if (K==1)
break
end
end
guidata(hObject, handles);
---------------------------------------------------------------------
function rd_1_Callback(hObject, eventdata, handles)
if (get(hObject,'Value') == get(hObject,'Max'))
handles.b=1;
else
handles.b=2;
end
guidata(hObject, handles);
----------------------------------------------------------------------
trying "K=handles.b" Instead of typing "K=1" above
I want,while loop "for", any button or raddio_button or listbox ,stop with an impact.
  댓글 수: 1
nsbd
nsbd 2011년 5월 8일
Please Help Me.

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

채택된 답변

Arturo Moncada-Torres
Arturo Moncada-Torres 2011년 5월 8일
Hello,
Quan Quach has an excellent tutorial regarding this issue. I this this is just what you need:
Regards,
Arturo M.
  댓글 수: 4
nsbd
nsbd 2011년 5월 8일
"
------------------------------------------------------------
function start_pushbutton_Callback(hObject, eventdata, handles)
set(handles.start_pushbutton,'UserData',1);
while (get(handles.start_pushbutton,'UserData') ==1)
temp = str2num(get(handles.counter_text,'String'));
temp = temp + 1;
set(handles.counter_text,'String',num2str(temp));
drawnow
end
guidata(hObject, handles);
--------------------------------------------------------------
function stop_pushbutton_Callback(hObject, eventdata, handles)
set(handles.start_pushbutton,'UserData',0);
guidata(hObject, handles);
"
Arturo Moncada-Torres
Arturo Moncada-Torres 2011년 5월 13일
I am glad it helped. I had the same issue and spend a lot of time searching for the answer. Cheers!

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 5월 8일
for i=1:n;
pause();
if (get(handles.b,'Value')==1)
break
end
end
  댓글 수: 1
Matt Fig
Matt Fig 2011년 5월 13일
I don't think the user wants to hit return every loop iteration!
pause(.001)

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by