MATLAB: In for loop, All the students are getting same grades

forif elselengthloopsize;

Hello, I was making code to sum, average and grade students based on marks of Maths, Chemistry and Physics. Sum and average is done but grading is not working. It is returning same grade to all students. Kindly Help, Regards.

Best Answer

You made the same mistake that people in the past have made asking this very same question.
Sum is an array so in a loop you need to use
Sum(i)
in all your elseif statements. You have a for loop looping round variable i, but you don't use i so you basically do the same thing every time round the loop.
There are neater ways to do it, but I'll ignore those for now and just do the minimal correction to the code you have.