delete row in matrix if value in another matrix is unique
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Frederik Reese
le 19 Juil 2022
Réponse apportée : Jonas
le 19 Juil 2022
Hi,
probably a simple question, but I need your help.
I have 2 matrices with 1 column each. Values appear twice in the first matrix (x1). I select this with unique and delete it. In the 2nd matrix (y1) I want to delete the same row as in matrix 1. So e.g. Row 12 contains twice the value and is deleted, then row 12 in the other matrix should also be deleted after that they should contain the same number of values.
The two matrices are attached
Thank you very much
0 commentaires
Réponse acceptée
Jonas
le 19 Juil 2022
you want to delete entries when the number is repeated first?
firstVec=[5 3 5 1 7 9 3 1 4];
secVector=1:numel(firstVec)
[~,firstOnly]=unique(firstVec,'stable')
% keep only entries at first number occurence
secVector(firstOnly)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!