Character Cell Array Comparison
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Seb
am 29 Jun. 2017
Bearbeitet: Andrei Bobrov
am 29 Jun. 2017
Ok, so excuse me; new to matlab and have not found a solution through google. I have a 3x2 cell array for example:
test = {'apple' 'banana'; 'banana' 'apple'; 'pear' '[]'}
And I want to compare the two columns (or however many there are) and return an array of all values that match. i.e return apple and banana from the test cell given. Essentially it just needs to discard any empty or unique values.
Any help much appreciated.
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 29 Jun. 2017
Bearbeitet: Andrei Bobrov
am 29 Jun. 2017
[a,~,c] = unique(test);
out = a(accumarray(c,1)>1 & ~strcmp(a,'[]'));
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!