matlab switch case 不太会用,程序一直有错.clc;clear;x=0:0.1*pi:2*pi;a=input('name:')switch acase 'sin'y=sin(x);plot(x,y)case 'cos'y=cos(x);plot(x,y)case 'tan'y=tan(x);plot(x,y)otherwisebreak;end

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/30 00:24:57
matlab switch case 不太会用,程序一直有错.clc;clear;x=0:0.1*pi:2*pi;a=input('name:')switch acase 'sin'y=sin(x);plot(x,y)case 'cos'y=cos(x);plot(x,y)case 'tan'y=tan(x);plot(x,y)otherwisebreak;end

matlab switch case 不太会用,程序一直有错.clc;clear;x=0:0.1*pi:2*pi;a=input('name:')switch acase 'sin'y=sin(x);plot(x,y)case 'cos'y=cos(x);plot(x,y)case 'tan'y=tan(x);plot(x,y)otherwisebreak;end
matlab switch case 不太会用,程序一直有错.
clc;
clear;
x=0:0.1*pi:2*pi;
a=input('name:')
switch a
case 'sin'
y=sin(x);
plot(x,y)
case 'cos'
y=cos(x);
plot(x,y)
case 'tan'
y=tan(x);
plot(x,y)
otherwise
break;
end

matlab switch case 不太会用,程序一直有错.clc;clear;x=0:0.1*pi:2*pi;a=input('name:')switch acase 'sin'y=sin(x);plot(x,y)case 'cos'y=cos(x);plot(x,y)case 'tan'y=tan(x);plot(x,y)otherwisebreak;end
不是case的问题,你这里case的用法没有问题
是输入语句的问题,应该改为
a=input('name:','s');
多一个参数's'表面输入的内容是字符串,就好了