find columns adjacent to logical values
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kendal
le 9 Nov 2022
Modifié(e) : Davide Masiello
le 9 Nov 2022
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 commentaires
Réponse acceptée
Davide Masiello
le 9 Nov 2022
Modifié(e) : Davide Masiello
le 9 Nov 2022
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!