Azzera filtri
Azzera filtri

what does ismember actually mean?

2 visualizzazioni (ultimi 30 giorni)
Muazma Ali
Muazma Ali il 25 Set 2019
Commentato: dpb il 27 Set 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 Commento
dpb
dpb il 27 Set 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.

Accedi per commentare.

Risposta accettata

Star Strider
Star Strider il 25 Set 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).

Più risposte (0)

Categorie

Scopri di più su Enumerations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by