## 算法介绍
% 开关切换分支机构的基本形式
%{
switch expression % 设置开关条件1
case Vorc1 % 分支情况1
(commands1)
case Vorc2
(commands2)
......
case Vorcn
(commandsn)
otherwise
(commanddefault)
end
%}
算法应用
grade = 'B';
switch(grade)
case 'A'
fprintf('Excellent!\n' );
case 'B'
fprintf('Well done\n' );
case 'C'
fprintf('Well done\n' );
case 'D'
fprintf('You passed\n' );
case 'F'
fprintf('Better try again\n' );
otherwise
fprintf('Invalid grade\n' );
end