Desperately need help with this matlab problem Function Name

Desperately need help with this matlab problem!!

Function Name GSquare Inputs 1. (double) A 1x(2*N 1) vector of homework grades 2. (double) A 1xN vector of comment grades 3. (char) An Nx3 character array representing the grade mode Outputs: 1. (double) The final homework grade Background: As part of an assignment to work on your WOVEN skills for English class, you are assigned a pen-pal in a foreign country who you correspond with through email and vlogs. It just so happens that your pen-pal happens to attend the best engineering school in Georgia, and is also currently taking a CS class! At the end of the semester, he informs you via vlog that his homework grades for the class are not reported correctly in his online gradebook since the software, GSquare, is incapable of taking into account whether a homework assignment is the maximum or average of his original and resubmission. Since h tells you that he too cannot do this simple math, and that his TAs told him at the beginning of the semester not to ask what his real homework grade should be, you offer to write a function that will do it for him Function Description: t input represents your homework grades, alternating between the respective assignment\'s original grade and resubmission grade. The rest of the elements follow this alternating pattern except for the final entry, which is the grade on the extra credit assignment. in1 [100 0 95 0 75 95 88] HW1 HW2 HW3 EC The second input represents your comment grades, which can add up to 10 additional points per homework. So a 95 comment grade adds 9.5 points in2 100 0 95 HW1 HW2 HW3 The third input will be a character amay with rows reading either avg\' or \'max\',which will determine whether you should take the average or maximum of the original and resubmission grades for the corresponding homework in avg max avg Use this information to calculate the overall homework grade. Remember that a resubmission can never hurt your grade, only improve it: if the resubmission grade is lower, or if the assignment was not re-submitted (represented by a 0), then the resubmission grade should

Solution

function grade = GSquare(hwGrades, commentGrades, gradeMode)
  
hwSize = length(commentGrades)
  
finalGrades = zeros(hwSize, 1)
  
for i = 1:hwSize
normal = hwGrades(2*i - 1)
resub = hwGrades(2*i)
com = commentGrades(i)
com = com /10.0
fin = 0
if resub == 0 || resub < normal
resub = normal
end
if gradeMode[0] == \'a\'
fin = (normal + resub)/2
else
fin = normal
end
fin = fin + com
finalGrades(i) = fin
end
  
min_ele = min(finalGrades)
grade_sum = sum(finalGrades)
if min_ele < hwGrades(2*hwSize+1)
grade_sum = grade_sum - min_ele + hwGrades(2*hwSize+1)
end
  
grade = grade_sum / hwSize
end

hwGrades = [100; 0; 95; 0; 75; 95; 95;75; 60;0;70]
length(hwGrades)
commentGrades = [100; 0; 75; 90; 50]
length(commentGrades)
gradeMode = [\'a\',\'v\',\'g\'; \'m\',\'a\',\'x\';\'a\',\'v\',\'g\';\'m\',\'a\',\'x\';\'a\',\'v\',\'g\';]

grade = GSquare(hwGrades, commentGrades, gradeMode)
grade = round(grade*10)/10.0

Desperately need help with this matlab problem!! Function Name GSquare Inputs 1. (double) A 1x(2*N 1) vector of homework grades 2. (double) A 1xN vector of comm
Desperately need help with this matlab problem!! Function Name GSquare Inputs 1. (double) A 1x(2*N 1) vector of homework grades 2. (double) A 1xN vector of comm

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site