- #1
gfd43tg
Gold Member
- 950
- 50
Homework Statement
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.
Homework Equations
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(:,:)));
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(:,:)));
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(:,:)));
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(:,:)));
8) alwaysLowest = 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
Attachments
Last edited: