This whole is a single question with just subparts. So, please don\'t delete thi
ID: 652329 • Letter: T
Question
This whole is a single question with just subparts. So, please don't delete this question.
Write a user-defined MATLAB function that calculates a student's final grade in a course using the scores from three midterm exams, a final exam, and six homework assignments. The midterms are graded on a scale from 0 to 100 and each accounts for 15% of the course grade. The final exam is graded on a scale from 0 to 100 and accounts for 40% of the course grade. The six homework assignments are each graded on a scale from 0 to 10. The homework assignment with the lowest grade is dropped, and the average of the remaining assignments accounts for 15% of the course grade. In addition, the following adjustment is made when the grade is calculated. If the average grade for the three midterms is higher than the grade for the final exam, then the grade of the final exam is not used and the average grade of the three midterms accounts for 85% of the course grade. The program calculates a course grade that is a number between 0 and 100. For the function name and arguments use g = fgrade(R). The input argument R is a matrix in which the elements in each row are the grades of one student The first six columns are the homework grades (numbers between 0 and 10), the next three columns are the midterm grades (numbers between 0 and 100), and the last column is the final exam grade (a number between 0 and 100). The output from the function, g, is a column vector with the student grades for the course. Each row has the course grade of the student with the grades in the corresponding row of the matrix R. The function can be used to calculate the grades of any number of students. For one student the matrix R has one row. Use the function for the following cases: Use the Command Window to calculate the course grade of one student with the following grades: 8,9,6,10,9, 7, 76,86,91,80. Write a program in a script file. The program asks the user to enter the students' grades in an array (one student per row). The program then calculates the course grades by using the function fgrade. Run the script file in the Command Window to calculate the grades of the following four students: This whole is a single question with just subparts. So, please don't delete this question.Explanation / Answer
function g = fgrade(R)
for i= 1:6
m = R(i,:);
if ~isvector(m)
error('Input must be a vector')
end
s=m[1];
sum=0;
for i=2:6
sum=sum+m[i];
if(s<m[i])
s=m[i];
end
end
sum=sum-s;
avg=sum/5;
contriH=(15*avg)/100;
for i=7:9
sum=sum+m[i];
end
avg=sum/3;
if(avg>m[10])
contriM=(85*avg)/100;
g=contriH+contriM;
end
contriM=(15*avg)/100;
contriF=(40*m[10])/100;
g=contriH+contriM+contriF;
end
end
Call the function from the command line.
z = [8,9,6,10,9,7,76,86,91,80:,]
fgrade(z)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.