1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Test Score relational operators MATLAB

  1. Jun 18, 2014 #1

    Maylis

    User Avatar
    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 (Text):
    everLowest = max(Grades(sNum,:) <= min(Grades(:,:)));
    7)
    Code (Text):
    neverLowest = min(Grades(sNum,:) >= min(Grades(:,:)));
    I run the autograder and get the error message:
    Code (Text):
    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 (Text):
    alwaysLowest = min(Grades(sNum,:) < min(Grades(:,:)));
    I get the following error for number 8
    Code (Text):
    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 (Text):
    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 (Text):
    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 (Text):
    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)
     

    Attached Files:

    Last edited: Jun 18, 2014
  2. jcsd
  3. Jun 18, 2014 #2

    AlephZero

    User Avatar
    Science Advisor
    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.
     
  4. Jun 18, 2014 #3

    Maylis

    User Avatar
    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 (Text):
    neverLowest = min(Grades(sNum,:) ~<= min(Grades(:,:)));
    Apparently ~<= is not equivalent to ''not less than or equal to'', so then what is??
     
    Last edited: Jun 18, 2014
  5. Jun 18, 2014 #4
    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 :)
     
  6. Jun 18, 2014 #5

    Maylis

    User Avatar
    Gold Member

    Sorry, cpscdave, I don't get the hint =(
     
  7. Jun 18, 2014 #6
    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
     
  8. Jun 18, 2014 #7

    Maylis

    User Avatar
    Gold Member

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

    Code (Text):
    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: Jun 18, 2014
  9. Jun 18, 2014 #8

    Maylis

    User Avatar
    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 (Text):
    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: Jun 18, 2014
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Test Score relational operators MATLAB
Loading...