if-then-elseのキーワード
条件が複数ある場合,キーワードelseif が便利です. 複数のelseifがある場合, 最初にtrue条件となったものが選択されます(他のものがtrueの場合でも).
elseif
a=1; if a==1 then disp("a equals 1") elseif a==2 then disp("a equals 2") elseif a==1 & a>0 then disp("this condition is true, but never will be selected, because it is the second true condition.") else disp("Case not handled.") end