Delete string element in array (Matlab) -


i have string: pairs = ['aa';'ab';'bb';'ac'; 'cc'; 'cb';'de'; 'bc']

how can delete element has same characters in string 'aa','bb', 'cc' ?

the expected output should be: out = ['ab';'ac';'cb';'de';'bc']

use logical indexing , compare first , second column:

out = pairs(pairs(:,1)~=pairs(:,2),:) 

for more general way (to cover rows more 2 characters) can create index of rows have elements equal each other using bsxfun:

allsame = any(~bsxfun(@eq, pairs, pairs(:,1)), 2); out = pairs(allsame,:); 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -