find columns adjacent to logical values
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Kendal
il 9 Nov 2022
Modificato: Davide Masiello
il 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 Commenti
Risposta accettata
Davide Masiello
il 9 Nov 2022
Modificato: Davide Masiello
il 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!