Logical Indexing Data Issue
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tyler Rolince
le 30 Mar 2016
Réponse apportée : Star Strider
le 30 Mar 2016
I'm working on a project where I'm given a large matrix. I'm trying to isolate all third column values that fit into a certain group (ie an array of all values in the third column when column 1 is equal to 5 and column 2 is equal to 4). I've tried using logical indexing to accomplish this but have so far failed. Any help would be greatly appreciated.
0 commentaires
Réponse acceptée
Star Strider
le 30 Mar 2016
Logical indexing is the way to go. You need to set the logic up correctly:
This works:
M = randi(9, 1000, 3); % Create Data
M(10, 1:2) = [5 4]; % Be Certain One Row Matches Criteria
Out = M((M(:,1) == 5) & (M(:,2) == 4), 3); % Desired Result
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!