Question
using matlab
Write a function that accepts an input vector of integer exam scores and outputs a two column cell array with the same number of rows as the input vector, Each cell in the first column should contain a score from the input vector, The cells in the second column should have strings that give the corresponding letter grade according to the following grading scale: Score values ranging from 90 to 100 receive an A. Score values ranging from 80 to 89 receive a B. Score values ranging from 70 to 79 receive a C. Score values ranging from 60 to 69 receive a D. Score values ranging from 0 to 59 receive an F. #FUNC, #CHAR, #CELL Solution function grade_roster = student_solution [scores] Enter the commands for your function here. You can change the names, but not the order, of the grade_roster = scores;
Explanation / Answer
% need to enter in format : [23,34,.....,10]
cnt = 0;
[sz] = size(vec);
for i=1:sz
if (vec(i) >90 and vec(i)<101)
output[i-1][0] = vec(i);
output[i-1][1] = 'A';
elseif (vec(i) >80 and vec(i)<91)
output[i-1][0] = vec(i);
output[i-1][1] = 'B';
elseif (vec(i) >70 and vec(i)<81)
output[i-1][0] = vec(i);
output[i-1][1] = 'C';
elseif (vec(i) >60 and vec(i)<71)
output[i-1][0] = vec(i);
output[i-1][1] = 'D';
else
output[i-1][0] = vec(i);
output[i-1][1] = 'F';
end