(1)单个的就如同C语言中的一样,不过在和switch使用的时候case后不用接:
n = input('Enter a number: ');switch ncase -1disp('negative one')case 0disp('zero')case 1disp('positive one')otherwisedisp('other value')
end
(2)多个的使用就用花括号
x = [12 64 24];
plottype = 'pie3';switch plottypecase 'bar' bar(x)title('Bar Graph')case {'pie','pie3'}pie3(x)title('Pie Chart')otherwisewarning('Unexpected plot type. No plot created.')
end