티스토리 뷰
1. Syntax
- while 조건
- 구문
- end
i = 0;
total = 0;
while i < 100
i = i + 1;
total = total + i;
end
disp(total);2. Skip to Next Iteration
- continue 키워드를 통해 다음 loop로 넘어갈 수 있음
i = 0;
total = 0;
while i < 100
i = i + 1;
if mod(i, 2) == 0
continue
end
total = total + i;
end
disp( total);3. Exit loop Before Expression Is False
- break 키워드를 통해 loop를 탈출
limit = 0.8;
s = 0;
while 1
tmp = rand;
if tmp > limit
break
end
s = s + tmp;
end
Reference: https://www.mathworks.com/help/matlab/ref/while.html
'Computer Language > Matlab' 카테고리의 다른 글
| 2d 그래프(plot) (0) | 2018.08.04 |
|---|---|
| if 문(if statements) (0) | 2018.08.02 |
| for 문(for loop) (0) | 2018.07.31 |
| 함수(Function) (0) | 2018.07.28 |
| 형태 변형(Reshape and Rearrange) (0) | 2018.07.27 |
댓글