How to extract indices with a condition?
79 次查看(过去 30 天)
显示 更早的评论
For example I have Y = X(X==42), but I need the indices also!
2 个评论
rbih rbih
2020-6-12
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.
采纳的回答
更多回答(1 个)
Walter Roberson
2018-3-26
find(X==42) and store in a variable. Then X(that_variable)
10 个评论
Walter Roberson
2024-2-29
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!