Logic Statements
Use relational operators in conjunction with the logical operators A & B (AND), A | B
(OR), xor(A,B) (XOR), and ~A (NOT), to string together more complex logical
statements.For example, you can locate where negative elements occur in two arrays.A = [2 -1; -3 10]A =2 -1
-3 10B = [0 -2; -3 -1]B =0 -2
-3 -1A<0 & B<0ans =0 1
1 0For more examples, see “Find Array Elements That Meet a Condition” on page 5-2.See Also
eq | ge | gt | le | lt | neMore About
- “Array vs. Matrix Operations” on page 2-13
- “Compatible Array Sizes for Basic Operations” on page 2-19
- “MATLAB Operators and Special Characters” on page 2-2
2 Program Components