18.1k views
0 votes
Write a function that accepts a cell array StudentScores consisting of the following:

a character array (i.e. text string) with a student's last name
a vector of their homework scores (HW) .
a vector of their quiz scores (QZ )
a vector of their exam scores (EX) .
a scalar with the final project score (PJ)
Your function should compute the total course score using the formula:
FinalScore = 0.25HW +0.20QZ +0.40EX +0.15PJ
where the bars indicate the average scores in each of the categories that have multiple scores. The final score should be stored in single precision. Your function should create and output a 1x2 cell array Finalscore with the student name in the first cell and the final score (in single precision) in the second cell.

1 Answer

3 votes

Answer:

function FinalScore = grades(StudentScores)

FinalScore ={StudentScores{1,:};0.25*mean(cell2mat(StudentScores{2,:}))+0.20*mean(cell2mat(StudentScores{3,:}))+0.40*mean(cell2mat(StudentScores{4,:}))+0.15*StudentScores{5,:}}

endfunction

Step-by-step explanation:

In the source code, the function FinalScore is defined to calculate the total student score and assign it to the variable FinalScore. Note that the code block in the function must be indented accordingly.

User Anshuman
by
5.5k points