问题1
function Rank = TranGrades(fen)
len = length(fen);
Rank = [];
for k = 1:len
CurMark = fen(k);
if CurMark>=90
Rank = strcat(Rank,'A');
continue;
end
if CurMark>=80
Rank = strcat(Rank,'B');
continue;
end
if CurMark>=70
Rank = strcat(Rank,'C');
continue;
end
if CurMark>=60
Rank = strcat(Rank,'D');
continue;
end
if CurMark<60
Rank = strcat(Rank,'E');
continue;
end
end
测试结果:
fen=[90,85,100,79,57];
Rank = TranGrades(fen)
Rank =
ABACE
问题2
syms x
f = x+cos(x)
an1 = subs(f,x,0)
an2 = subs(f,x,pi/2)
结果:
f =
x+cos(x)
an1 =
1
an2 =
1.5708