matlab switch case 语句不能用?(从书上抄的)程序如下for month =1:12;switchmonthcase{3,4,5} %元胞season='spring'case{6,7,8}season='summer'case{9,10,11}season='autumn'otherwiseseason='winter'endend

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/07 14:39:26

matlab switch case 语句不能用?(从书上抄的)程序如下for month =1:12;switchmonthcase{3,4,5} %元胞season='spring'case{6,7,8}season='summer'case{9,10,11}season='autumn'otherwiseseason='winter'endend
matlab switch case 语句不能用?(从书上抄的)
程序如下
for month =1:12;
switchmonth
case{3,4,5} %元胞
season='spring'
case{6,7,8}
season='summer'
case{9,10,11}
season='autumn'
otherwise
season='winter'
end
end

matlab switch case 语句不能用?(从书上抄的)程序如下for month =1:12;switchmonthcase{3,4,5} %元胞season='spring'case{6,7,8}season='summer'case{9,10,11}season='autumn'otherwiseseason='winter'endend
错误在于switch month 中间有一个空格,程序是对的