c=0;
b=[0,0,0,0,0];
for a = [76,71,92,92.76,75,86,88,93,72,78,88,87,79,60,93,77,73,91,85,63,84,60,87]
if a >= 90
b(1)=b(1)+1;
elseif( a < 90 && a >= 80 )
b(2)=b(2)+1;
elseif( a < 80 && a >= 70 )
b(3)=b(3)+1;
elseif( a < 70 && a >= 60 )
b(4)=b(4)+1;
else
b(5)=b(5)+1;
end
c=c+1;
end
fmt=[‘OUT=[’ repmat(’ %d’,1,numel(b)) ‘]\n’];
fprintf(fmt, b);
%76,71,92,92.76,75,86,88,93,72,78,88,87,79,60,93,77,73,91,85,63,84,60,87
function MyProgram()
a=[76,71,92,92.76,86,88,93,87,79,96];%10门课的成绩
b=zeros(1,10);
disp(a);
disp(b);
for i = 1:10
c=a(i);
d=myfun©;
b(1,i) =double(d);
end
fprintf(‘%8.1f’b);
fprintf(’%8.1f’a);
end
function [y] = myfun (x)
%声明名为 myfun 的函数,该函数接受输入 x1,…,xM 并返回输出 y1,…,yN。
y=vpa((floor(x)/10),2);
end