필터 지우기
필터 지우기

what does ismember actually mean?

조회 수: 2 (최근 30일)
Muazma Ali
Muazma Ali 2019년 9월 25일
댓글: dpb 2019년 9월 27일
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
dpb
dpb 2019년 9월 27일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2019년 9월 25일
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).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Enumerations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by