(MATLAB PROGRAM) Write a Matlab program that will read the scores from a RawScor
ID: 3673432 • Letter: #
Question
(MATLAB PROGRAM)
Write a Matlab program that will read the scores from a RawScores.txt and compute the numerical average and the letter grade for each student.
The results should be displayed in the file: FinScores.txt
The data file contains four columns in the following order from left to
right: Student Number, HW Average, Test Average, Final Exam score.
Numerical Averages are computed according to the formula below.
HW 20%, Tests 35%, Final Exam 45% rounded to the nearest whole number
Letter grades are assigned based on the following curve.
A >= Mean Numerical Average + 1.5* Standard Dev of Numerical Averages
B >= mean + 0.5*Stdev and less than mean + 1.5*Stdev
C >= mean - 0.5*Stdev and less than mean + 0.5*Stdev
D >= mean - 1.5*Stdev and less than mean - 0.5*Stdev
F < mean - 1.5*Stdev
Below you can find the raw scores:
---------------------------------
---------------------------------
Explanation / Answer
fh = fopen('RawScores.txt ', 'r');
line = '';
ca = {};
while ischar(line)
line = fgetl(fh);
[first line] = strtok(line);
[last line] = strtok(line);
grades = sscanf(line, '%f %f %f %f %f %f');
if 'A'
grades = 4;
elseif 'B'
grades = 3;
elseif 'C'
grades = 2;
elseif 'D'
grades = 1;
else
grades = 0;
GPA= (grades(1) + grades(2) + grades(3) + grades(4)+grades(5)+grades(6))/length(scores)
ca = [ca; {first last GPA}];
end
end
xlswrite('FinScores.txt', ca);
fclose(fh);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.