Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Write a loop which will be increasing variable i by 5 at each iteration till i reaches 50. Initial value of i is 12.
조회 수: 1 (최근 30일)
이전 댓글 표시
im having a bit trouble with loops if somone can help me with this answer and explain as well it would be nice
댓글 수: 0
답변 (1개)
Walter Roberson
2019년 10월 7일
편집: Walter Roberson
2019년 10월 7일
for VARIABLENAME = FIRST_VALUE : INCREMENT : LAST_VALUE
something
end
is nearly equivalent to
VARIABLENAME = FIRST_VALUE;
while VARIABLE_NAME <= LAST_VALUE
something
VARIABLE_NAME = VARIABLE_NAME + INCREMENT;
end
(The differences between the two have to do with the value that VARIABLENAME is left at if FIRST_VALUE > LAST_VALUE when INCREMENT is positive, or FIRST_VALUE < LAST_VALUE when INCREMENT Is negative; and also have to do with the value that VARIABLENAME will be left with after the last iteration in two different situations.)
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!