How to filter a 'tall' array using multiple conditions?

6 ビュー (過去 30 日間)
Johannes Koch
Johannes Koch 2018 年 1 月 27 日
コメント済み: Adam Filion 2018 年 4 月 23 日
I'm trying to get some data out of 'tall' arrays, with multiple conditions. So for example if my 'tall' array has 5 columns, I want to filter the array with conditions on multiple columns. 'find' doesn't work...
  3 件のコメント
Johannes Koch
Johannes Koch 2018 年 1 月 29 日
Thanks a lot for you comment !!! I didn't know about logical indexing... I managed now to extract the data I was looking for but it isn't pretty (and not very fast if I want to look up stuff often, I think). What I'm doing is: using logical indexing to get a tall array the same length as my tall table (from which I'm looking to extract the data), then adding this array to the table, then gathering the desired table columns with the condition that the logical value must be true. Do you perchance know a smarter way? Here are the lines I'm talking about:
% tt is my original tall table with all the data
% logtt is my logical tall array reflecting my conditions
tt=[tt,array2table(logtt,'variablenames',{'check'})];
result=gather(tt(tt.check,1:6))
Adam Filion
Adam Filion 2018 年 4 月 23 日

Do you need to return the 'check' value for some reason? It will always have the value of 'true'. If not it should be more efficient to return only the tall table itself without appending the logical index to it.

result = gather(tt(logtt,1:6));

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeTall Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by