If I am asking for a matlab code in a question you should copy-paste the text fr
ID: 3663331 • Letter: I
Question
If I am asking for a matlab code in a question you should copy-paste the text from the.m file that corresponds to that question. If I am asking for a written explanation, then you should submit the written explanations.
Question 6 Write a MATLAB function that calculates the final numeric grades of students and returns a letter grade according to the following scheme Letter Grade Criteria 80 S numeric grade S 100 60 S numeric grade 80 40 S numeric grade 60 numeric grade 40 Details about the MATLAB function: function name: letterGrade input A where A is a matrix of size m x 3 (m 1). Each row of A matrix contain grades that belong to a student in EGM 3344. In addition, the first column of A matrix contains grades of Hwi, the second column of A matrix contains grades of HW2, and finally the third column of A matrix contains grades of HW3. An example of matrix A is given as follows: A [80 90 100; 75 45 60] According to the given A matrix above, the first student got 80 from Hwi, 90 from HW2, and 100 from HW3 and the second student got 75 from Hwi, 45 from HW2, and 60 from HW3. Numeric grade of each student is calculated as the average of Hwi, HW2, and HW3. Accord- ing to the given A matrix above, the numeric grade of the first student is 90 and the numeric grade of the second student is 60. Output: grades where grades is a matrix of size m x 2. The first column contains the numeric grades and the second column contains the letter grades. For A matrix given above, output grades would be as follows: grades 190 A 60 BJExplanation / Answer
So, I am copy-pasting the text from the .m file that corresponds to this question. ;)
function [ grades ] = letterGrade( A )
%Calculates the final numeric grades of students
%and returns a letter grade
% You can't have a matrix contain numbers and letters both
% So, you need a cell here
grades = cell(size(A,1), 2);
for i = 1:size(A,1)
tempSum = 0;
for j = 1:size(A,2)
tempSum = tempSum + A(i,j);
end
grades{i,1} = tempSum/size(A,2);
if grades{i,1} >= 80
grades{i,2} = 'A';
elseif grades{i,1} >= 60
grades{i,2} = 'B';
elseif grades{i,1} >= 40
grades{i,2} = 'C';
else
grades{i,2} = 'F';
end
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.