How to extract indices with a condition?
79 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mr M.
am 26 Mär. 2018
Kommentiert: Walter Roberson
am 29 Feb. 2024
For example I have Y = X(X==42), but I need the indices also!
2 Kommentare
rbih rbih
am 12 Jun. 2020
hi Mr M. i just wondering about the value that you're searching index for (42), isn't that related to the quiz of rigid body kinematics course (Concept Check 9 - Euler Angle Differential Kinematic Equations) on coursera!
just for fun, have a good day.
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 26 Mär. 2018
find(X==42) and store in a variable. Then X(that_variable)
10 Kommentare
Walter Roberson
am 29 Feb. 2024
setdiff(1:numels(X), ind0)
returns all the indices of X that do not appear in ind0
It is questionable whether this will be any faster than
X(X ~= 0)
but the original poster wanted a different way.
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!