Using listdlg, with muitlple selection to plot graphs

I am using 'listdlg' function with the Mutiple selection, so the user can select two different items from a list with Mutiple items. When two items are selected, I want the program to plot one bar graph. How would use 'if' or 'case' statements to do this. The list: rain sun snow wind
for example, if 'rain and sun' are selected, it plots (x,y) whereas if 'snow' and 'wind' are selected, it plots (s,t) any help would be much appreciated thanks alot.

 採用された回答

VBBV
VBBV 2022 年 12 月 8 日
編集済み: VBBV 2022 年 12 月 8 日

0 投票

list = {'Rain','Sun','Snow','Wind'};
[indx,tf] = listdlg('ListString',list)
if tf
if strcmp(string(list(indx(1))),"Rain") & strcmp(string(list(indx(2))),"Sun")
disp('plotting Rain and Sun')
%plot here
elseif strcmp(string(list(indx(1))),"Snow") & strcmp(string(list(indx(2))),"Wind")
disp('plotting Snow and Wind')
%plot here
else
disp('Incorrect selection')
end
else
disp('Please make a selection')
end
you can use if-else to check the selection and plot accordingly

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeWind Power についてさらに検索

質問済み:

2022 年 12 月 8 日

編集済み:

2022 年 12 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by