Different output for find(X) and find(X<5)
Ältere Kommentare anzeigen
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)
Akzeptierte Antwort
Weitere Antworten (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
am 3 Dez. 2022
1 Stimme
>> X
X =
4 5 6 0 -1 3 0
>> X>0
ans =
1 1 1 0 0 1 0
Torsten
am 3 Dez. 2022
1 Stimme
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.
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!