필터 지우기
필터 지우기

insert end at right location

조회 수: 1 (최근 30일)
fatemeh
fatemeh 2013년 12월 29일
댓글: Roger Stafford 2013년 12월 29일
i have very nested for loop but when i want insert end for them i cannot insert them in the right locations i want do it arbitrary
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 12월 29일
I am not sure what you mean by "insert end" ?

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

채택된 답변

Roger Stafford
Roger Stafford 2013년 12월 29일
Your phrase "insert end" looks as though you had some action in mind but couldn't think how to say it in English.
I will make a wild guess that you want to know how to make a complete exit out of some nested for-loops at some point. If so, matlab's 'break' function can be used to do that. Just do a 'break' in each for-loop. Here's an example with four nested for-loops:
b = false;
for ...
for ...
for ...
for ...
% At some point you decide to leave the for-loops by making b true
if b, break, end
end
if b, break, end
end
if b, break, end
end
if b, break, end
end

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 12월 29일
Try typing control-a control-i to fix up the indenting. It will let you see where you've messed up. Also if you click on the if/while/for, or the "end", it will show you briefly for a second or two where the matching line of code is.
  댓글 수: 1
Roger Stafford
Roger Stafford 2013년 12월 29일
Yes, Image Analyst, that's more likely what Fatemeh meant. I didn't think of that possibility. This guesswork is sometimes the hardest part of answering.

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

카테고리

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