- 21
- 0
- 约3.33千字
- 约 6页
- 2019-05-31 发布于浙江
- 举报
实验三
1. a=[-5 -3 1 2 2.5 3 5];
for i=1:6
x=a(1,i)
if x0x~=3
y=x^2+x-6
elseif x=0x5x~=2x~=3
y=x^2-5*x+6
else y=x^2-x-1
end
end
2.用if语句编写
grade=input(please input the grade which is between 0 and 100);
a=floor(grade/10);
if a=0a6
disp(E)
elseif a=6a7
disp(D)
elseif a=7a8
disp(C)
elseif a=8a9
disp(B)
elseif a=9a=10
disp(A)
else disp(error!)
end
用swich语句编写
grade=input(please input the grade which is between 0 and 100);
if grade0
disp(error!)
else switch fix(grade/10);
case num2cell(0:5)
disp(E)
case{6}
disp(D)
case{7}
disp(
原创力文档

文档评论(0)