matlab编程练习题

来源:百度知道 编辑:UC知道 时间:2024/05/31 22:03:39
从键盘上输入数字星期,在屏幕上显示对应英文星期的单词。

function week
n=input('input the number:');
if isempty(n)
errror('please input !!')
end
if n>7|n<1
error('n between 1 and 7')
end

switch n
case 1
disp('Monday')
case 2
disp('Tuesday')
case 3
disp('Wednesday')
case 4
disp('Tuesday')
case 5
disp('Friday')
case 6
disp('Saturday')
case 7
disp('Sunday')
end

在命令窗口输入 week,剩下的看着办吧~~~