Simple Way to Find How Far Down a Number Is
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I was wondering if there is a simple way to determine which row a number appears?
For example, if I have a large table with the last column is either a 1 or 0, if I want to know which row holds a 0, how can I make an array that essentially says: The value 0 appears in rows 1, 34, 89, ...
I found this forum post, which goes over how to pull a number from a column of the same row based on the value in another column.
I was thinking I could make a new column that just numbers from 1 to N (where N is the number of rows) and add that as a new column to the table.
Then using the technique from the linked forum post, save the number (value) from the added column into an empty matrix (an all-zero array from 1 to N).
Then after that, remove all the zeros and be left with an array that only has the postitions of where the 0 is in the original column.
This method seems long but it can work, I was just wondering if there is something simpler to do.
Thanks.
0 件のコメント
採用された回答
Star Strider
2022 年 11 月 2 日
T1 = array2table([rand(10,3) randi([0 1], 10, 1)])
RowIdx = find(T1.Var4 == 0)
.
.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!