find columns adjacent to logical values
1 次查看(过去 30 天)
显示 更早的评论
I have a table with 891 rows and 12 colums. I have sorted 1 column logically (0's and 1's) and need to pull out data from 2 other columns adjacent to the 1's.
Any assistance will be greatly appreciated!
0 个评论
采纳的回答
Davide Masiello
2022-11-9
编辑:Davide Masiello
2022-11-9
Reductive example.
Assume this is your matrix
A = rand(10,5)
and let's assume your logical criteria is that you want to extract all the values in column 3 and 5 that correspond to values in column one which are greater than 0.5.
Then you simply do
b = A(A(:,1) > 0.5,3) % extracts values from 3rd colum that correspond to values > 0.5 in the first column
c = A(A(:,1) > 0.5,5) % extracts values from 5th colum that correspond to values > 0.5 in the first column
You can easily apply these indexing criteria to your case.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!