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

What do you need to do? Write a function with one input and two outputs called g

ID: 3732251 • Letter: W

Question

What do you need to do? Write a function with one input and two outputs called get_data. The function will read an excel file and return the relevant data. 1. The input will be the filename (a string) that we wish to read. b. a. The two outputs will be spreadsheet spreadsheet. i. num the matrix containing the numeric data in the ii. txt the cell array containing the text data in the 2. Write a function with two inputs and two outputs named scores a. The two inputs will be i. num, txt The variables returned from part 1. The two outputs will be b. i. mc The multiple choice scores for each student. ii ess - The essay scores for each student. 3. Write a function with two inputs and two outputs named calc_grades The two inputs will be i. mc, ess The multiple choice and essay scores from part2. a. b. The output will be i. grades - The final grades for each student. A student's final grade will be calculated using the following formula: grade-, (#correct answers for MC part) * 5 + (Essay score) 4. Using the above functions, create a script that calculates the students' final grades and plots a histogram of the data with bins of [10, 20, 90, 100)

Explanation / Answer

% Matlab function : getData.m 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.m 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.m 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

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