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

6 views (last 30 days)
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 Comments
Johannes Koch
Johannes Koch on 29 Jan 2018
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 on 23 Apr 2018

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));

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!