what does ismember actually mean?

2 views (last 30 days)
Muazma Ali
Muazma Ali on 25 Sep 2019
Commented: dpb on 27 Sep 2019
S={'NH4Cl'; 'MgCl2'; 'CaCl2'; 'ZnCl2'; 'ZnSO4'; 'NaCl'};
str={'Choose the combinations of salts available'};
result=listdlg('Promptstring',str, 'ListSize', [100,100], 'ListString', S, ...
'SelectionMode', 'multiple');
if all(ismember(result,[1 3]))
disp('hei')
end
in this code (all (ismember...), does the chronology of user's choice has to say anything or does ismember mean that user could have chosen the item 1 first and then 3 or 3 first and then 1? asking because then I have to take this into account in the if statement
  1 Comment
dpb
dpb on 27 Sep 2019
The logical vector returned by ismember is relative to the members in the first argument in the call -- in your case the array result. However, as you've written it with all, the condition will only be true if the user selects both 1 and 3 from the dialog box -- probably not what you're after.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 25 Sep 2019
If I understand your Question correctly, the logical vector created by ismember will be in the order the elements appear in ‘result’. However that is likely irrelevant because you are calling the all function. So either they both match (the all condition will be true) or one or none match (the all condition will be false).

More Answers (0)

Categories

Find more on Enumerations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!