Using the listdlg function

조회 수: 23 (최근 30일)
callum hayes
callum hayes 2022년 11월 30일
댓글: Walter Roberson 2022년 12월 3일
I am using the listdlg function and using 'Multiple' so the user can select mulitple items. When using the 'if,elseif' or the 'case' statements, they wont work when selecting mutiple items. They will work however if i only select one item from the list. The case statement spits out the code 'SWITCH expression must be a scalar or a character vector' and the 'if' statement spits a vector when i am trying to plot multiple bar graphs.
Any help would be great thanks.
  댓글 수: 2
Luca
Luca 2022년 12월 3일
Same problem for me, the output is a vector but I dont know what to do with it. (Im still a newbie)
Walter Roberson
Walter Roberson 2022년 12월 3일
Like @Les Beckham shows, loop over the values returned by listdlg()

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

채택된 답변

Les Beckham
Les Beckham 2022년 11월 30일
You probably just need to wrap your switch/case processing in a for loop. For example:
s = listdlg('ListString', {'One', 'Two', 'Three'});
for ii = 1:numel(s)
switch s(ii)
case 1
% do something
case 2
% do something different
case 3
% do something else
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by