command similar to setdiff for case insensitive

9 ビュー (過去 30 日間)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015 年 6 月 25 日
回答済み: Titus Edelhofer 2015 年 6 月 25 日
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

採用された回答

Titus Edelhofer
Titus Edelhofer 2015 年 6 月 25 日
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 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by