Matlab Relational & Logical Operations Quiz
40 questions on MATLAB's comparison and logical operators, covering equality, inequality, boolean logic, and common pitfalls.
Question 1
Which operator checks if two values are equal?
Question 2
What is the result of `5 > 3`?
Question 3
Which operator means 'not equal to'?
Question 4
What is the primary difference between `=` and `==`?
Question 5
Which symbol represents the logical AND operator (element-wise)?
Question 6
What is the result of `true | false`?
Question 7
What does the expression `~(5 > 10)` evaluate to?
Question 8
If `A = [1 0 1]` and `B = [0 1 1]`, what is `A & B`?
Question 9
Which operator represents 'greater than or equal to'?
Question 10
What is the data type of the result of a relational operation?
Question 11
What is the result of `NaN == NaN`?
Question 12
Which function returns true if *any* element in a vector is non-zero (true)?
Question 13
What does `3 < 5 < 4` evaluate to in MATLAB?
Question 14
Which operator is the 'Short-Circuit AND'?
Question 15
How do you check if two arrays `A` and `B` are identical in size and content?
Question 16
What is the result of `xor(true, true)`?
Question 17
Which function checks if a value is infinite?
Question 18
If `v = [10 20 30]`, what does `v > 15` return?
Question 19
How do you convert a numeric array `A` to logicals (0 becomes false, non-zero becomes true)?
Question 20
What is the correct way to check if `x` is between 1 and 10 (inclusive)?
Question 21
What does `~[0 1 0]` result in?
Question 22
Which operator has the highest precedence?
Question 23
What is the result of `strcmp('apple', 'apple')`?
Question 24
Why is comparing floating point numbers with `==` dangerous (e.g., `0.1 + 0.2 == 0.3`)?
Question 25
What does `all([1 1 0])` return?
Question 26
Which keyword represents the logical value 'true'?
Question 27
What is the result of `1 | 0 & 0`?
Question 28
How do you find the indices of all elements in `v` that are greater than 5?
Question 29
What happens if you use `&&` on arrays (e.g., `[1 0] && [0 1]`)?
Question 30
What is the logical negation of `x > 5`?
Question 31
Which function allows you to compare two strings case-insensitively?
Question 32
What is the result of `logical(5)`?
Question 33
If `A` is a logical array, how do you convert it back to 1s and 0s of type double?
Question 34
What does `isempty([])` return?
Question 35
Can you use logical arrays to index into other arrays?
Question 36
What is the result of `false < true`?
Question 37
Which operator is used for 'Element-wise OR'?
Question 38
What does `bitand(5, 3)` do?
Question 39
If `x = 5`, what is `x ~= 5`?
Question 40
What is the result of `any([0 0 0])`?
