A comparison operator is applied to a function that returns logical values
(true
or false
). In this case, the
comparison always returns the logical negation of the function output.
Therefore, it is either unnecessary or performed incorrectly.
If you want to perform a comparison, rewrite your code by placing the operator inside the function call. Otherwise, simplify your code by replacing the comparison statement with the logical negation of the function call.
This example shows how to rewrite your code. Option 1 (B1
)
shows how to simplify your code to determine whether one or more elements in
each column of a matrix A
are 0
. Option 2
(B2
) shows how to perform a comparison to determine
whether all elements in each column of A
are equal to
0
.
Original | Revised | |
---|---|---|
A = [0 3 5 1; 0 0 -2 1];
|
A = [0 3 5 1; 0 0 -2 1];
|