what does ismember actually mean?

2 visualizaciones (últimos 30 días)
Muazma Ali
Muazma Ali el 25 de Sept. de 2019
Comentada: dpb el 27 de Sept. de 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 comentario
dpb
dpb el 27 de Sept. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 25 de Sept. de 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).

Más respuestas (0)

Categorías

Más información sobre Enumerations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by