Counting how many times an option is selected inside a loop
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
gotjen
2021-5-12
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!