# Test Score relational operators MATLAB

#### Maylis

Gold Member
1. The problem statement, all variables and given/known data
Hello, I am working on problems 6-14 on the attached PDF. Don't be scared off, they are just one line of code each. I got number 6 correct, and I got partial credit on 7 and 8, but I am trying to figure out why it is not right.

2. Relevant equations

3. The attempt at a solution
Here is the code for 6, which is correct.
Code:
everLowest = max(Grades(sNum,:) <= min(Grades(:,:)));
7)
Code:
neverLowest = min(Grades(sNum,:) >= min(Grades(:,:)));
I run the autograder and get the error message:
Code:
Problem 7: 3/5
*the value of neverLowest is incorrect for the variables: sNum = 27;
Incompatible logical variables
*the value of neverLowest is incorrect for the variables: sNum = 77;
Incompatible logical variables
8)
Code:
alwaysLowest = min(Grades(sNum,:) < min(Grades(:,:)));
I get the following error for number 8
Code:
Problem 8: 4/5
*the value of alwaysLowest is incorrect for the variables: sNum = 112;
Incompatible logical variables
So I know the autograder runs for about 5 values of sNum. My code works for some of the values of sNum, but not all. I don't understand why these codes are not valid for all values of sNum?

This is my english translation of the code, I want to know if I am understanding this correctly. I will use #6 as my example since I got full credit for that problem.
Code:
everLowest = max(Grades(sNum,:) <= min(Grades(:,:)));
means the maximum grade of a particular student (sNum) on every exam (:) is less than or equal to the minimum grade of all other students on all other exams (min(Grades(:,.

Edit: Apparently the answer lies in the fact that I needed to change the >= to > for (7), and < to <= for (8), but I don't see exactly why. The signs are confusing the heck out of me

Here are the new correct answers
Code:
7) neverLowest = min(Grades(sNum,:) > min(Grades(:,:)));
9) everHighest = max(Grades(sNum,:) >= max(Grades(:,:)));
And here is (10)
Code:
neverHighest = max(Grades(sNum,:) <= max(Grades(:,:)));
Problem 10: 4/5
*the value of neverHighest is incorrect for the variables: sNum = 18;
Incompatible logical variables
It's now at the point where I am just switching mins, max, and the direction of the inequality symbol as well as tacking on an = until I get it right. I am missing something fundamental and must not be comprehending the questions correctly. Ideally I should be able to read the question and know which way to put the signs and whether or not to have an equal in the inequality (choosing between ≤ or <, etc)

#### Attachments

• 22.5 KB Views: 94
Last edited:
Related Engineering and Comp. Sci. Homework News on Phys.org

#### AlephZero

Homework Helper
For 7, the opposite of "less than or equal" is not "greater than or equal". Alternatively, find out how to say "not" directly in Matlab.

For 8, compare questions between 6 and 8. The only difference is the word "any" in 6 and "all" in 8. Think about what that difference means, if student snum scored say 10, 25, 30 on 3 tests, and another student scored 15, 20, 25.

#### Maylis

Gold Member
That is so confusing to me. How is the opposite of ''less than or equal'' not ''greater than or equal''?

For 7, if I just add the not to 6, it gets it wrong.

Code:
neverLowest = min(Grades(sNum,:) ~<= min(Grades(:,:)));
Apparently ~<= is not equivalent to ''not less than or equal to'', so then what is??

Last edited:

#### cpscdave

5 is less than or equal to 6
6 is less than or EQUAL to 6
6 is greater than or EQUAL to 6
6 is NOT greater than 6

if that makes sense :)

#### Maylis

Gold Member
Sorry, cpscdave, I don't get the hint =(

#### cpscdave

The opposite of Less than or equal would be strictly greater than :) The counter example being 6
as both
6<=6 and 6>=6 are true, which implies that the <= and >= operators are not opposite of one another

#### Maylis

Gold Member
Why is it for 7 I get full credit, but 10 only 4/5 points?

Code:
neverLowest = min(Grades(sNum,:) > min(Grades(:,:)));
neverHighest = max(Grades(sNum,:) < max(Grades(:,:)));
Also Dave, now I get what you were saying. That is good to know

Last edited:

#### Maylis

Gold Member
Okay, the only one I am stuck on now is number 14

Assign to the variable curveBusters an S-by-1 array (S may be 0) of the student numbers whose
average score (across all tests) was strictly higher than average score of the student indicated by
sNum.

here is my code

Code:
S = 0;
curveBusters = find(mean(Grades(sNum,:)) < mean(Grades(:,:)));
I have to find the students who had a higher average score that sNum across all tests, but this is not the right code. My code should be finding the mean of the student sNum across all exams, then the mean of all students across all exams, and whoever has a higher overall mean than sNum is what should show. That is what I intend this code to do, but I can't tell why it is not working.

Last edited:

"Test Score relational operators MATLAB"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving