How to exclude rows on the basis of specific entries?
Mostra commenti meno recenti
I have 260 rows and 16 columns with entries belong to {1,2,3,4}, I want to exclude those rows in which first four entries of each row is 4 , or in general how can I exclude rows on the basis of entries?
Risposta accettata
Più risposte (1)
Jos (10584)
il 6 Feb 2018
Here is a flexible example:
% data
X = [4 4] ; % rows starting with this should be discarded
A = [1 4 1 4 ; 4 4 2 2 ; 4 2 4 0 ; 4 4 4 4 ; 2 4 4 2] ; % rows 2 and 4 should be discarded
% engine
tf = ismember(A(:,1:numel(X)), X, 'rows')
A(tf) = [] ; % remove
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!