Filter löschen
Filter löschen

Counting how many times an option is selected inside a loop

1 Ansicht (letzte 30 Tage)
Cathan Ivory
Cathan Ivory am 12 Mai 2021
Beantwortet: gotjen am 12 Mai 2021
I am trying to create a piece of code that will display how many times an option from the list has been selected. I have a loop that will keep occuring until the user has finished inputting the data. Here is a section of that code.
for k = 1:1:A(w,2)
normal=normal+1;
list = {'Resident','Education','Office','Toilet','Storage'};
[indx,tf] = listdlg('PromptString',sprintf('On Floor %d what spaces are used ',w)...
,'SelectionMode','single','ListString',list);
typeofspace = list{indx};
Thanks
  1 Kommentar
gotjen
gotjen am 12 Mai 2021
Please use code formating on your code. Highlight the code and press alt+enter

Melden Sie sich an, um zu kommentieren.

Antworten (1)

gotjen
gotjen am 12 Mai 2021
You could track the selections with an array like
list = {'Resident','Education','Office','Toilet','Storage'};
count = zeros(size(list))
for kk = ...
[indx,tf] = listdlg(...)
count(indx) = count(index)+1;
end

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by