关于matlab的switch语句,请帮我找找错误price = input('input price');switch fix(price/100) case [0, 1] rate = 0; case [2, 3, 4] rate = 0.03; case [5, 6, 7, 8, 9] rate = 0.05; otherwise rate = 0.1;end
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 22:26:13
关于matlab的switch语句,请帮我找找错误price = input('input price');switch fix(price/100) case [0, 1] rate = 0; case [2, 3, 4] rate = 0.03; case [5, 6, 7, 8, 9] rate = 0.05; otherwise rate = 0.1;end
关于matlab的switch语句,请帮我找找错误
price = input('input price');
switch fix(price/100)
case [0, 1]
rate = 0;
case [2, 3, 4]
rate = 0.03;
case [5, 6, 7, 8, 9]
rate = 0.05;
otherwise
rate = 0.1;
end
为什么无论我输入什么数字结果都是0.1?
关于matlab的switch语句,请帮我找找错误price = input('input price');switch fix(price/100) case [0, 1] rate = 0; case [2, 3, 4] rate = 0.03; case [5, 6, 7, 8, 9] rate = 0.05; otherwise rate = 0.1;end
clear;
clc;
price = input('input price:');
switch fix(price/100)
case {0, 1}
rate = 0;
case {2, 3, 4}
rate = 0.03;
case {5, 6, 7, 8, 9}
rate = 0.05;
otherwise
rate = 0.1;
end
rate
注意:使用{} 不用[]
结果示例:
input price:350
rate =
0.0300