find columns adjacent to logical values
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Kendal
am 9 Nov. 2022
Bearbeitet: Davide Masiello
am 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 Kommentare
Akzeptierte Antwort
Davide Masiello
am 9 Nov. 2022
Bearbeitet: Davide Masiello
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!