matlab switch语句strmonth = menu('please choose a month','Janurary','February','March','April','May','June','July','August','September','October','November','December');switch strmonthcase 'Janurary'a = 31;case 'February'a = 28;case 'March'a = 31;c
matlab switch语句strmonth = menu('please choose a month','Janurary','February','March','April','May','June','July','August','September','October','November','December');switch strmonthcase 'Janurary'a = 31;case 'February'a = 28;case 'March'a = 31;c
matlab switch语句
strmonth = menu('please choose a month','Janurary','February','March','April','May','June','July','August','September','October','November','December');
switch strmonth
case 'Janurary'
a = 31;
case 'February'
a = 28;
case 'March'
a = 31;
case 'April'
a = 30;
case 'May'
a = 31;
case'June'
a = 30;
case 'July'
a = 31;
case 'August'
a = 31;
case 'September'
a = 30;
case 'October'
a =31;
case 'November'
a =30;
case 'December'
a =31;
end
disp(a);
选择,2月,出错:Undefined function or variable 'a'.
Error in ==> month at 30
disp(a);
这是为什么.
matlab switch语句strmonth = menu('please choose a month','Janurary','February','March','April','May','June','July','August','September','October','November','December');switch strmonthcase 'Janurary'a = 31;case 'February'a = 28;case 'March'a = 31;c
strmonth = menu('please choose a month', 'Janurary', 'February','March','April','May','June','July','August','September','October','November','December');
switch strmonth
case 1
a = 31;
case 2
a = 28;
case 3
a = 31;
case 4
a = 30;
case 5
a = 31;
case 6
a = 30;
case 7
a = 31;
case 8
a = 31;
case 9
a = 30;
case 10
a =31;
case 11
a =30;
case 12
a =31;
end
disp(a);