Hi guys, wonder how to transfer grade into letter grade. I have already calculated the code, which is following:
NA = 4;PS = [75, 62, 80, 71, 0, 32, 56, 80];PR = 68;EM = 78;n=2;u=unique(PS)if numel(u)==1 || numel(u)==2 Result=[]else Result=mean(PS(~ismember(PS,u(1:n))))enda = Resultif NA <= 2 b = 15endif NA == 3 b = 14endif NA == 4 b = 13endif NA == 5 b = 12endif NA == 6 b = 11endif NA == 7 b = 10endif NA == 8 b = 9endif NA == 9 b = 8endif NA == 10 b = 7endif NA == 11 b = 6endif NA == 12 b = 5endc = PR*0.3d = EM*0.2e = a*0.35grade = b + c + d + eNA = 1;PS = [90, 100, 100, 84, 89, 92, 73];PR = 96;EM = 0;n=2; % two smallest values
u=unique(PS)if numel(u)==1 || numel(u)==2 Result=[]else Result=mean(PS(~ismember(PS,u(1:n))))enda = Resultif NA <= 2 b = 15endif NA == 3 b = 14endif NA == 4 b = 13endif NA == 5 b = 12endif NA == 6 b = 11endif NA == 7 b = 10endif NA == 8 b = 9endif NA == 9 b = 8endif NA == 10 b = 7endif NA == 11 b = 6endif NA == 12 b = 5endc = PR*0.3d = EM*0.2e = a*0.35grade = b + c + d + e
I know I am super unskilled lol. Anyway, at first I tried
function grade=letter_grade if grade >= 91 letter_grade='A'; elseif n >= 81 letter_grade='B'; elseif n >= 71 letter_grade='C'; elseif n >= 61 letter_grade='D'; else letter_grade='F'; endend
but it doesn't work. Please help me with that, thanks in advance.
PS: 90-100 A+ 80-89 A 70- 79 B 60-69 C 50-59 D below 50 F
Best Answer