티스토리 뷰
1. Syntax
a = [1 2 3 1 0 1];
for i = 1:1:length(a)
if a(i) == 1
disp('a는 1입니다.')
elseif a(i) == 0
disp('a는 0입니다.')
else
disp('a는 1이 아닙니다.')
end
end
2. Evaluate Multiple Conditions in Expression
x = 10;
minVal = 2;
maxVal = 6;
if (x >= minVal) && (x <= maxVal)
disp('Value within specified range.')
elseif (x > maxVal)
disp('Value exceeds maximum value.')
else
disp('Value is below minimum value.')
end
Reference: https://www.mathworks.com/help/matlab/ref/if.html
'Computer Language > Matlab' 카테고리의 다른 글
| 바둑판식 그래프(subplot) (0) | 2018.08.05 |
|---|---|
| 2d 그래프(plot) (0) | 2018.08.04 |
| while 문(while loop) (0) | 2018.08.01 |
| for 문(for loop) (0) | 2018.07.31 |
| 함수(Function) (0) | 2018.07.28 |
댓글