0

yesterday I posted this question but the friend who help me to solve this question didn't reply me, the line which he wrote have an error. Could any other person help me; I tried myself but didn't find what i want. briefly, I want to delete duplicated rows say:{'A','B'; 'B', 'A';'C', 'D'; 'C','D'} and keep only one single rows like this:{'A','B';'C','D'}

Example:

'TPB' 'TP53'

'ELL' 'TP53'

'SIT1' 'GRB2'

'ROHA' 'BRCA1'

'TP53' 'ELL'

'ROHA' 'BRCA1'

desired output:

'TPB' 'TP53'

'ELL' 'TP53'

'SIT1' 'GRB2'

'ROHA' 'BRCA1'

https://drive.google.com/file/d/0B6u8fZadKIp2bEVCN1IxVDBBWG8/view

3
  • Possible duplicate of how to remove identical rows and duplicated rows from a cell array? Commented May 21, 2017 at 9:45
  • Plz any help i tried but no results !!!! Commented May 21, 2017 at 9:45
  • @ RTL, I said that I already posted this questions but the guy who put the code didn't reply me because the second part of his code has an error and I need help to fix it if its right Commented May 21, 2017 at 9:49

1 Answer 1

1

you want unique rows of cell array of strings. you can use unique on cell entries to get numeric matrix and then use unique (again) with argument 'rows' on the matrix to get the unique rows:

% input cell
C = {'TPB' 'TP53';
    'ELL' 'TP53';
    'SIT1' 'GRB2';
    'ROHA' 'BRCA1';
    'TP53' 'ELL';
    'ROHA' 'BRCA1'};
% get unique cell entries as a numeric array
[~, ~, num] = unique(C,'stable');
% sort columns to eliminate [a,b;b,a] situations
num = sort(reshape(num,size(C)),2);
% get unique rows indexes
[~,idx,~] = unique(num,'rows');
res = C(idx,:)

outputs:

4×2 cell array

'TPB'     'TP53' 
'ELL'     'TP53' 
'SIT1'    'GRB2' 
'ROHA'    'BRCA1'
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks friend for your answer but i get this error: Index exceeds matrix dimensions. Error in PPIHumanNet_datas (line 31) uniqueRows = rows(doubleUnique);
i' m working with a huge in put cell of size <36888x2 cell>
i can share it with you if its possible
upload it to some file sharing system (google drive, dropbox, etc.) and share download link
I have edited the question and share the data and many thanks for your willng to help me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.