Why is the result of my logical indexing smaller than the original vector?
4 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2017 年 7 月 5 日
回答済み: MathWorks Support Team
2017 年 7 月 5 日
I have a vector "x" and a logical indexing vector "idx", which is the same size as "x". However, when I index into "x" using "idx", the result is a different size.
Why does this happen?
採用された回答
MathWorks Support Team
2017 年 7 月 5 日
Logical indexing in MATLAB only returns values for the locations where indexing vector is 1, any other values from the original vector are ignored.
To acquire a result of the same size of "x" and "idx", you can consider using the "element-wise multiplication" operator ( .* ), or the "logical and" operator ( & ). For more information, please refer to the following documentation page on Matrix Indexing:
https://www.mathworks.com/help/matlab/math/matrix-indexing.html#bq7egb6-1
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
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!