excel and matlab problem
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have this set of data and i want to grade the average grades and output each students result with the grade. Currently the code still does not assign the grades with the averages. Kindly assist
T = readtable('C:\Users\RONNIE\Documents\EXCEL.xlsx');
NAMES = T.(1) ;
format short
AvgMarks = mean(table2array(T(:,2:end)),2) ;
if (70<=AvgMarks)&(AvgMarks<=100)
fprintf ('A')
elseif (60<=AvgMarks)&(AvgMarks<=69)
fprintf ('B')
elseif (50<=AvgMarks)&(AvgMarks<=59)
fprintf ('C')
elseif (40<=AvgMarks)&(AvgMarks<=49)
fprintf ('D')
else
fprintf ('E')
end
Tavg = table(NAMES,AvgMarks)
STUDENTRESULTS=T(1,1:end)
format short
0 Kommentare
Akzeptierte Antwort
Voss
am 20 Jul. 2022
T = readtable('EXCEL.xlsx');
NAMES = T.(1) ;
AvgMarks = mean(table2array(T(:,2:end)),2) ;
Grades = cell(size(T,1),1);
Grades(AvgMarks >= 70) = {'A'};
Grades(AvgMarks >= 60 & AvgMarks < 70) = {'B'};
Grades(AvgMarks >= 50 & AvgMarks < 60) = {'C'};
Grades(AvgMarks >= 40 & AvgMarks < 50) = {'D'};
Grades(AvgMarks < 40) = {'E'};
Tavg = table(NAMES,AvgMarks,Grades)
2 Kommentare
Voss
am 20 Jul. 2022
T = readtable('EXCEL.xlsx');
NAMES = T.(1) ;
AvgMarks = mean(table2array(T(:,2:end)),2) ;
Grades = cell(size(T,1),1);
Grades(AvgMarks >= 70) = {'A'};
Grades(AvgMarks >= 60 & AvgMarks < 70) = {'B'};
Grades(AvgMarks >= 50 & AvgMarks < 60) = {'C'};
Grades(AvgMarks >= 40 & AvgMarks < 50) = {'D'};
Grades(AvgMarks < 40) = {'E'};
Tavg = table(NAMES,AvgMarks,Grades);
student_name = 'Raquel Bass'
student_grade = Tavg{strcmp(Tavg.NAMES,student_name),'Grades'}
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!