To find all of the rows in a MATLAB table with a certain value, you can use logical indexing. Logical indexing allows you to create a logical (boolean) vector that indicates which rows of a table meet a certain condition.
Suppose you have a table T with columns A, B, and C, and you want to find all of the rows where the value in column A equals x. Here's an example code block that shows how to do this:
main.m265 chars10 lines
In the above code block, the logical indexing expression T.A == 2 creates a logical vector that indicates which rows of T have 2 in the A column. We then use this logical vector to select the corresponding rows from T using the notation T(idx, :), which returns a new table that includes only the rows indexed by idx.
You can modify the logical indexing expression to match your own criteria for finding rows with a certain value. For example, to find rows where column C contains the string 'foobar', you can use the expression contains(T.C, 'foobar').
gistlibby LogSnag