x=0:2*pi/100:2*pi;
y1=x.^2;
y2=cos(2*x);
y3=y1.*y2;
plot(x,y1,'-r');
hold on
plot(x,y2,'*b');
hold on
plot(x,y3,'--y');
figure
subplot(3,1,1);
plot(x,y1,'-r');
subplot(3,1,2);
plot(x,y2,'*b');
subplot(3,1,3);
plot(x,y3,'--y');
8.a=input('please input a core between 100 and 0 :');
b=floor(a/10);
switch b
case {9,10}
disp('A');
case 8
disp('B');
case 7
disp('C');
case 6
disp('D');
otherwise
disp('E');
end
第7题
x=-1:0.01:1;
y1=x.^2;
y2=cos(2*x);
y3=y1.*y2;
figure(1),
plot(x,y1,'r-');hold on
plot(x,y2,'g--');
plot(x,y3,'b-.');hold off
figure(2),
subplot(311),plot(x,y1);
subplot(312),plot(x,y2);
subplot(313),plot(x,y3);
第8题
a=input('输入成绩:');
switch floor(a/10)
case {9,10}
b='A';
case 8
b='B';
case 7
b='C';
case 6
b='D';
otherwise
b='E';
end
disp(['成绩等级:' b]);