matlab switch语句
发布网友
发布时间:2022-04-25 08:53
我来回答
共2个回答
热心网友
时间:2023-11-10 21:19
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);追问= =。知道了
热心网友
时间:2023-11-10 21:20
注意看最后一行代码最后的分号 发现是中文状态下输入的分号 改过来 应该改就可以了
希望能帮助到你追问不是,我就写一个a,也是报错:ndefined function or variable 'a'.
热心网友
时间:2023-11-10 21:19
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);追问= =。知道了
热心网友
时间:2023-11-10 21:20
注意看最后一行代码最后的分号 发现是中文状态下输入的分号 改过来 应该改就可以了
希望能帮助到你追问不是,我就写一个a,也是报错:ndefined function or variable 'a'.
热心网友
时间:2023-11-10 21:20
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);追问= =。知道了
热心网友
时间:2023-11-10 21:20
注意看最后一行代码最后的分号 发现是中文状态下输入的分号 改过来 应该改就可以了
希望能帮助到你追问不是,我就写一个a,也是报错:ndefined function or variable 'a'.
热心网友
时间:2023-11-10 21:20
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);追问= =。知道了
热心网友
时间:2023-11-10 21:20
注意看最后一行代码最后的分号 发现是中文状态下输入的分号 改过来 应该改就可以了
希望能帮助到你追问不是,我就写一个a,也是报错:ndefined function or variable 'a'.