search smaller string array to bigger string array

how can i search 'selected' string array to bigger 'alllistarray' and index as 'mask'
selected={'a', 'gg' 'c'}
Alllist={'a', 'b' ,'d' 'ee' ,'ff' 'gg',}
%%result should be like this
mask=[0 0 1]

 Accepted Answer

selected={'a', 'gg' 'c'};
Alllist={'a', 'b' ,'d' 'ee' ,'ff' 'gg'};
mask = ~ismember(selected,Alllist)
mask = 1x3 logical array
0 0 1
or
mask = ~contains(selected,Alllist)
mask = 1x3 logical array
0 0 1

1 Comment

joms
joms on 22 Jan 2021
Edited: joms on 22 Jan 2021
exactly what i wanted . thank you

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2016b

Asked:

on 22 Jan 2021

Edited:

on 22 Jan 2021

Community Treasure Hunt

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

Start Hunting!