Different output for find(X) and find(X<5)
Show older comments
Whereas the command [row, col, val] = find(X) returns the original values of X in val, the command [row, col, val] = find(X>0) returns logical value in val. What is the reason behind such behaviors?
X = [4, 5, 6, 0, -1, 3, 0];
[row, col, val] = find(X)
[r, c, v] = find(X>0)
Accepted Answer
More Answers (3)
Because the argument you've passed to find() is (X>0) which is a logical array. Therefore, the values returned are taken from that:
X = [4, 5, 6, 0, -1, 3, 0];
A=(X>0)
Muu
on 3 Dec 2022
1 vote
>> X
X =
4 5 6 0 -1 3 0
>> X>0
ans =
1 1 1 0 0 1 0
Torsten
on 3 Dec 2022
1 vote
find(X) lists the array elements of the double array X that are not equal 0.
find(X>0) lists the array elements of the logical array X>0 that are true.
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!