📅  最后修改于: 2021-01-07 02:11:48             🧑  作者: Mango
如果要检查的选项或条件不只一个,请使用elseif关键字。
if expression
Statements
elseif expression
Statements
else
Statements
end
% program to compare two numbers
% generate random number for your age
n = randi(100,1);
age = 23;
% check the number is greater than your age
if n > age
disp('i am younger')
elseif n < age
disp('you are younger')
else
disp('we are of same age')
end
输出:
n = 9
you are younger