Find row index of first 'True' value in column of table
32 次查看(过去 30 天)
显示 更早的评论
I have a table (called T) of multiple columns of different types (int & string). One column (called 'active' - last column) is made up of 'True' and 'False' values.
I need to get the row index corresponding to the first instance of a 'True' value in that specific column.
When i subset this column out, using x = T.active; I get a cell containing the True/False strings.
The data looks like this:
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995400000000 0.320874800000000 -0.243447200000000 -0.391341200000000 3 0.600000000000000 0.300000000000000 'False' 'False'
0.533995200000000 0.320874700000000 -0.243447100000000 -0.391341100000000 3 0.600000000000000 0.300000000000000 'False' 'True'
0.533995300000000 0.320876000000000 -0.243452500000000 -0.391338100000000 3 0.600000000000000 0.300000000000000 'False' 'True'
0.533996300000000 0.320879000000000 -0.243463900000000 -0.391332500000000 3 0.600000000000000 0.300000000000000 'False' 'True'
0.533998800000000 0.320884400000000 -0.243480800000000 -0.391323600000000 3 0.600000000000000 0.300000000000000 'False' 'True'
0 个评论
采纳的回答
更多回答(1 个)
KSSV
2019-4-16
Let T be your table.
idx = contains(T.active,'True') ;
iwant = find(idx)
T(idx,:)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!