티스토리 뷰

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
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/12   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함