Help with Table and Row indexing
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have the following table Predictions, where there are 2 Days, 2 different Time points, for 2 different Birds, 3 Tries per day.
I want to:
- Check If the Row number is a True Positive (meaning the column True and Predicted have the same value)
- Check If the Row number is a True Positive and the Predicted value is '1'. Save those Row numbers in a variable called RN.
- From another table T with the same dimentions as the Predictions table, I only want to keep the Row numbers as assigned to RN.
Can you help?
0 commentaires
Réponse acceptée
Voss
le 14 Mai 2022
Modifié(e) : Voss
le 14 Mai 2022
S = load('predictions.mat');
Predictions = S.Predictions
isTruePositive = Predictions{:,'True'} == Predictions{:,'Predicted'};
isTruePositivePredicted1 = isTruePositive & Predictions{:,'Predicted'} == 1;
% here are the row numbers:
RN = find(isTruePositivePredicted1)
% Two different ways to keep only certain rows
% of the other table T:
% Option 1: use logical indexing, and discard
% rows of T that are not true positive where
% 1 was predicted (in this case you don't need RN):
T{~isTruePositivePredicted1,:} = [];
% Option 2: use row indices RN to keep those rows
% that are true positive where 1 was predicted:
T = T{RN,:};
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical 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!