command similar to setdiff for case insensitive
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gopalakrishnan venkatesan
am 25 Jun. 2015
Beantwortet: Titus Edelhofer
am 25 Jun. 2015
Is there any command similar to setdiff for case insensitive. As setdiff is case sensitive?
for example a = {'car','book,'glass'}
b = {'CAr','book','glass'}
c = setdiff(a,b)
returns the same array a(because setdiff does not work for car insensitive)
how can i do this? because i have two cell array which is really large.
running in loop by strcmpi and finding the index will take some time.
is it possible to excute in single command as like setdiff?
Thank you
0 Kommentare
Akzeptierte Antwort
Titus Edelhofer
am 25 Jun. 2015
Hi,
if two commands is fine as well, you can do the following:
% find index of elements in a that are in b:
[flag,idx] = ismember(lower(a), lower(b));
% remove the found elements:
a(idx(flag)) = [];
Titus
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numeric Types 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!