Matlab Grade book help --drop one lowest score and assigning letter grade
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi I am building a gradebook that allows me to drop the lowest assignment score and only takes 10 assignment scores and adds all the test scores. I need to assign a letter grade to each student.
Here is some data

I am stuck on dropping the lowest score and assigning students to a grade in my function. if there is a better way of doing it without a function... please tell me...
function [sumarr] = grades(structure, field)
% FUNCTION GRADES accepts any cell array value and assigns a letter
% all data entered must be transposed from rows to colums please remember
% to transpose data example transposedata = data' ---> data = [FILE that
% was imported]
%DEFINE VARIABLES
% ii -- index variable
ii =0 ;
array =[];
for ii = 1:length(structure)
%build an array
array = [array structure(ii).(field)];
end
% if one grade is less than 2, drop the score.
% assign Letter grades
%sum of all grades
sumarr = sum(array);
end
3 commentaires
Réponse acceptée
Image Analyst
le 29 Nov 2014
Can you try just subtracting the min, something like
array = [structure.(field)]; % All items - no loop over ii needed.
arraySum = sum(array) - min(array);
8 commentaires
Mohammad Abouali
le 1 Déc 2014
Modifié(e) : Mohammad Abouali
le 1 Déc 2014
ImageAnalyst has already answered your question. Just one more note:
another way of grading without multiple if/else is this
levels=[59 69 79 89];
GradeLetter={ 'F', ...
'D', ...
'C', ...
'B', ...
'A'};
if (arraySum<0 || arraySum >100)
error('Imposible grade')
else
fprintf(' final grade : %.3f\t %s\n', ...
arraySum, ...
GradeLetter{imquantize(arraySum,levels)} )
end
This makes it easier to change the code and add more grade levels later, such as B+, B-, A+, A-
imquantize() is part of image processing though. You need to have that toolbox.
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!