Help with extracting info from a listbox in a specific way
Show older comments
Hello. I am using a uitable (in APPDesigner) to get user defined positions to move a stage to and take an image. There are 9 rows and 12 columns.

As can be seen, the red cells have been selected and this "list of positions" is populated in a listbox.

As I want to scan in the row direction (shown by black arrow), I want to collect all Row 1 positions, Row 2 positions etc and add to a string that I can then pass to a move routine for the stage.
"row =ALL" means all rows at that column are required, so this is the strings that Im trying to achieve by looping through the list box items, but dont know how to.
i.e. in row 1, all the columns 2,4,5,10,1 need to be scanned, so a string like:
"r1,2,4,5,10,1"
and row 2, the columns 2,4,5,10,1 need to be scanned, so
"r2,2,4,5,10,1"
...and for row 9
"r9,1,7"
This is my attempt
%Get number of items in listbox
items=app.ListBox.Items
nl=numel(items)
s1='r1,'
for i=1:nl
line=(items(i))
%get row
if contains(line, 'ALL')
disp(['Found at line',num2str(i)])
b=regexp(line,'\d+(\.)?(\d+)?','match')
b=b{1}
cl=b{1,1}
cl= convertCharsToStrings(cl)
class(cl)
s1=strjoin(s1,cl)
break
end
end
Or if its easier, an array of string arrays output would be ok
"r1" "2" "4" "5" "10" 1"
"r2" "2" "4" "5" "10" 1"
Thanks for any help
Accepted Answer
More Answers (0)
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!