Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem1: Write a MATLAB script (code) that reads an input file containing all t

ID: 3717788 • Letter: P

Question

Problem1: Write a MATLAB script (code) that reads an input file containing all the scores of 40 students. The MATLAB code should also calculate the weighted average score (see the weights below) in percent and the assign a letter grade to each student per the following scale. Your code should write an output file to list all the letter grades for all 30 students.

Table 1. Weight of each score components

Score Components

Weight

Quizzes

15%

Homework assignments

15%

Midterm exam 1

25%

Project

15%

Midterm exam 2

30%

Score Components

Weight

Quizzes

15%

Homework assignments

15%

Midterm exam 1

25%

Project

15%

Midterm exam 2

30%

Explanation / Answer

ANS:-

PROGRAM:-

% Matlab script to read a file containing the marks of 40 students
% input file format : quiz homework midterm1 project midterm2 for each
% student in separate line

clc;
score = importdata('student_data.txt',' '); % import file and create matrix score containing data from file
% calculate weighted average
WAvg = zeros(size(score,1),1);
for i = 1:size(score,1)
WAvg(i) = (15*score(i,1)+15*score(i,2)+25*score(i,3)+15*score(i,4)+30*score(i,5))/100;
end
% calculate grade
grade = blanks(size(WAvg,1));
for i = 1:length(WAvg)
if(WAvg(i)>=90)
grade(i) = char('A');
elseif(WAvg(i)>=70)
grade(i) = char('B');
elseif(WAvg(i)>=55)
grade(i) = char('C');
elseif(WAvg(i)>=40)
grade(i) = char('D');
else
grade(i) = char('F');
end
end
% write grade to output file
filename = 'grade.txt';
file = fopen(filename,'w');
dlmwrite(filename,grade,'delimiter',' ');
fclose(file);
% end of script

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote