The language is Matlab What is given? You are given one file named section9_data
ID: 3728637 • Letter: T
Question
The language is Matlab
What is given? You are given one file named section9_data.xlsx which contains (see figure below) 1. The answer key for the multiple-choice part of the quiz (cells G2:W2) 2. The student ID numbers (column B), 3. The score the students received for the Essay portion of the quiz (column E), 4. The section number (column F), 5. The student answers to each of the 17 multiple-choice questions (columns G through W). Student ID No. Score Multiple-choice Essay Section Q1 Q2 Q3 Q4 as Q6 Q7 Q8 Q9 Q10q11 Q12 Q13 Q14 Q15 Q16 Q17 CSCI1320000'3 CSCI1320000'4 CSC11320000'17 CSC1132000018 CSC11320000'59 CSCI11320000'60 CSCI1320000 61 SC11320000 90 CSC11320000 91 CSC11320000'92 CSC11320000'114 CSCI1320000'115 CSCI1320000'147 CSC11320000'14B 3011320000'188 CSC11320000'210 CSC11320000'211 CSCI1320000'275 CSCI1320000'276 CSC11320000'277 3011320000'278 CSC11320000'279 CSC11320000 280 CSCI1320000 281 9 D B B 9 D B B B A B A D DBA A AB D B 9 A A BC AA A C C AA A D 7 ,C A C A B D B C BA BA BB BD 9D B CD A E B D DB A B B B AD C 9DACCABDCDA AABBBB 9 D B CB AC A D D D B A B B AD C 13 10 9 D 10 9D 9D BBBACBDDBBA88AD B 9CCCCACDCACCACCCC 9DBBBABBDADBSBAAC 17 18 19 14 9 D A C A A B A B A A A A D D 14 9 C 15 9A 15 9 DACCABD8CBA88BBD A CCABD8ACAA8888C 15 9 D A CCA AD B A B A B B BC 15 9 D A B CA A D B A A A B D 15 9 D ABCAADAAAA8 8 8 0 15 25Explanation / Answer
% Matlab function to get data from an excel file
% input is the filename
% outputs : num - matrix containing the numeric data
% txt - cell array containing the text data
function [num,txt] = getData(filename)
[num,txt] = xlsread(filename);
end
% end of function
% Matlab function scores that calculates the essay and multiple choice
% scores for each student
% inputs : num - matrix containing the numeric data
% txt - cell array containing the text data
% outputs : mc - multiple choice scores of each student
% ess - essay scores of each student
function [mc,ess] = scores(num,txt)
ess = zeros((size(num,1)-1),1);
mc = zeros(size(ess));
% get the essay score
for i=2:size(num,1)
ess(i-1) = num(i,3);
end
% get the multiple choice score by matching the user's answer against
% the correct answer
for i=3:size(txt,1)
for j=7:size(txt,2)
if(txt{i,j} == txt{2,j})
mc(i-2) = mc(i-2) + 1;
end
end
end
end
% end of function
% Matlab function calc_grades to calculate the grade of students
% inputs : mc - multiple choice scores of each student
% ess - essay scores of each student
% output: grades - the final grades for each student.
function grades = calc_grades(mc,ess)
grades = zeros(size(mc));
% calculate the final grade
for i =1:size(mc,1)
grades(i) = (mc(i)*5) + ess(i);
end
end
% end of function
% Matlab script to read a file and calculate final grades for students and
% plot a histogram of the data with bins of [10,20,30,...,90,100]
% input fo file
file = input(' Enter the name of the input file :','s');
% get data from file
[num,txt] = getData(file);
% get scores
[mc,ess] = scores(num,txt);
% get final scores
grades = calc_grades(mc,ess);
% plot histogram with bin size 10
histogram(grades,10);
xlabel('Grade');
ylabel('Number of students');
% end of script
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.