MATLAB: Need help With Matlab Project

deleting part of matrixelseelseififremoving minimum value

Problem 4: The overall grade in a course is determined from the grades of 5 quizzes, 3 midterms, and a final, using the following scheme:
Quizzes: Quizzes are graded on a scale from 0 to 10. The grade of the lowest quiz is dropped and the average of the 4 quizzes with the higher grades constitutes 25% of the course grade.
Midterms: Midterms are graded on a scale from 0 to 100. If the average of the midterm scores is higher than the score on the final, the average of the midterms is 35% of the course grade. If the final grade is higher than the average of the midterms, then the lowest midterm is dropped and the average of the two midterms with the higher grades is 35% of the course grade.
Final: Finals are graded on a scale from 0 to 10. The final is 40% of the course grade. Write a computer program in a script file that determines the course grade for a student. The program first asks the user to enter the five quiz grades (in a vector), the three midterm grades (in a vector), and the grade of the final. Then the program calculates a numerical course grade (a number between 0 and 100). Finally, the program assigns a letter grade according to the following key:
A for grade >= 90, B for 80<= grade <= 90, C for 70 <= grade <= 80, D for 60 <= grade <= 70, and E for a grade lower than 60. Execute the program for the following cases:
(a) Quiz grades: 7, 9, 4, 8 , 7. Midterm grades: 93, 83, 87. Final grade: 89.
(b) Quiz grades: 8, 6, 9, 6 , 9. Midterm grades: 81, 75, 79. Final grade: 72.
I keep getting an error when trying to use if and else to create a scheme for the Midterms. I have attached two pics (input and output) to display an example of my issue.

Best Answer

min(Midterms) returns the value of the minimum, not the location of the minimum. You should do
[~, minidx] = min(Midterms);
Midterms(minidx) = [];
Note, by the way, that you of code of the form
if first condition;
do first something
else second condition
do second something
end
What this means to MATLAB is the same as
test first condition without displaying any result because "if" just doesn't
display the results of the condition no matter if ";" is there or not
if first condition was all true
do first something
display result of doing first something because there was no ";" at the end
of the calculation
otherwise
test second condition as an expression, because it is *not* in an "if" or "while" case
display result of testing second condition, because it was just a line of code and
there was no semi-colon to say not to display
throw away result of testing second condition because it was just a line of code, not an if or while
do second something
display result of doing second something because there was no ";" at the end of
the calculation
end
... All of which is a long way to point out that if you only want "do second something" to be done if the second condition is true, then what you need is an "elseif" rather than an "else".
However you make it an "elseif" then consider: what should you do if neither the first condition nor the second condition is true? In MATLAB it is possible for neither to be true: for example if the values were all NaN.