필터 지우기
필터 지우기

For with Break

조회 수: 1 (최근 30일)
nsbd
nsbd 2011년 5월 7일
Hi all.Please Help me.
How I can use for with break. "
for i=1:n;
%action
if H == 1 ; break
end
end
  댓글 수: 1
nsbd
nsbd 2011년 5월 7일
this don't work

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

채택된 답변

Teja Muppirala
Teja Muppirala 2011년 5월 7일
Seems like you've got the right idea:
for n=1:100
disp(n)
if n == 7
disp('Hello everybody')
break
end
end
  댓글 수: 2
Teja Muppirala
Teja Muppirala 2011년 5월 7일
One more example:
n = 100;
for k=1:n
k
H = k^2;
if H == 36
disp('H is now 36. I will stop')
break
end
end
nsbd
nsbd 2011년 5월 7일
Ty
this is happening.but I realized.
all prog.
"
--------------------------------------------------------------
function pushbutton2_Callback(hObject, eventdata, handles)
pause(1.5)
import java.awt.Robot;
import java.awt.event.*;
key = Robot ;
H = Handles.K ;
n = 1000 ;
for i=1:n;
key.keyPress(java.awt.event.KeyEvent.VK_Z);
key.keyRelease(java.awt.event.KeyEvent.VK_Z);
pause(0.01)
key.keyPress(java.awt.event.KeyEvent.VK_5);
key.keyRelease(java.awt.event.KeyEvent.VK_5);
if H == 1
break
end
end
% Update handles structure
guidata(hObject, handles);
-------------------------------------------------------------------------
function rd_1_Callback(hObject, eventdata, handles)
%raddio button
if (get(hObject,'Value') == get(hObject,'Max'))
handles.K=1;
else
handles.K=2;
end
% Update handles structure
guidata(hObject, handles);
------------------------------------------------------------------------
1.in part H=1; or H=2; the program works.but I hope ;
2.in part raddio button clicked H After entering the values.prog. stoped.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by