How to extract indices with a condition?
76 ビュー (過去 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!