listbox, get items below selection
1 view (last 30 days)
Show older comments
Hi. I have a listbox containing about 40 image filenames.
I want to select one (I do this using the mouse), and then take that one and the 5 filename below it and process them.
This is my code:
Selected = get(handles.listbox1, 'value')
for n = Selected:Selected+6
tilect=1
baseImageFileName = strcat(cell2mat(ListOfImageNames(n)))
fullImageFileName = [folder '\' baseImageFileName]; % Prepend folder.
file=fullImageFileName
setappdata(0,'filename',file); % Save for later
IM = imread(file);
figure(findobj('Name','Tiles')) %plot to figure already open
subplot(1,6,tilect)
tilect=tilect+1;
end
But its giving me an error
Undefined function or variable "ListOfImageNames".
0 Comments
Accepted Answer
Image Analyst
on 13 Oct 2014
You need to load the image names into the cell array before you go into the loop:
ListOfImageNames = get(handles.listbox1, 'String');
Then in the loop I think you can just extract the string:
baseImageFileName = ListOfImageNames{n};
fullImageFileName = fullfile(folder, baseImageFileName); % Prepend folder.
3 Comments
Image Analyst
on 13 Oct 2014
Oh, okay, right. Just don't set tilect = 1 at the top inside of the loop or it will never change.
More Answers (0)
See Also
Categories
Find more on Subplots 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!