A comparison operator is applied to a function that returns logical values
(true
or false
). In this case, the
comparison always returns the same value as the logical function. 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 function call.
This example shows how to rewrite your code. Option 1 (B1
)
shows how to simplify your code to determine whether all elements in each column
of a matrix A
are nonzero. Option 2 (B2
)
shows how to perform a comparison to determine whether all elements in each
column of A
are equal to 1
.
Original | Revised | |
---|---|---|
A = [0 3 5 1; 0 0 -2 1];
|
A = [0 3 5 1; 0 0 -2 1];
|