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.

 Réponse acceptée

VBBV
VBBV le 8 Déc 2022
Modifié(e) : VBBV le 8 Déc 2022
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

Plus de réponses (0)

Catégories

En savoir plus sur Wind Power dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by