Filter löschen
Filter löschen

Multiselect from listbox and apply to subplot

1 Ansicht (letzte 30 Tage)
Jason
Jason am 18 Jun. 2014
Bearbeitet: Dishant Arora am 19 Jun. 2014
Hi. I have a listbox that I populate with say 100 images from a particular directory. I want to be able to select 7 of them, rotate them 90 degrees and then display next to each other in a subplot.
This is my code below for a single image selection, (note that the x position of the position vector for subplot requires the user to change a number in an edit box).
Thanks Jason
ListOfImageNames = get(handles.listbox1, 'string')
baseImageFileName = strcat(cell2mat(ListOfImageNames(Selected)));
fullImageFileName = [folder '\' baseImageFileName]; % Prepend folder.
figure(100);
file=fullImageFileName
IM = imread(file);
IM=imrotate(IM,angle);
subpos
x=0.101*(subpos-1)
positionVector = [0.0+x, 0.8, 0.1, 0.1];
subplot('Position',positionVector);
%subplot(4,7,subpos);
imagesc(IM,[0 5000])
colormap (gray);
axis off;
set(gca,'ytick',[]);
set(gca,'xtick',[]);

Akzeptierte Antwort

Dishant Arora
Dishant Arora am 18 Jun. 2014
Change the max and min property of listbox. Refer this link : http://www.mathworks.in/help/matlab/ref/uicontrol_props.html#bqxoinq
If max-min >1, you can select multiple elements from listbox.
  2 Kommentare
Jason
Jason am 19 Jun. 2014
How do you then access those selected items? Thanks
Dishant Arora
Dishant Arora am 19 Jun. 2014
Bearbeitet: Dishant Arora am 19 Jun. 2014
Use ctrl or shift key to access multiple items. Listbox callback is executed at every mouse click or keypress, so you might have to associate a push button with it to direct a callback. See this prototype:
function pushbutton1_callback(hObject , eventdata , handles)
fileNames = get(handles.listbox1 , 'string')
ind = get(handles.listbox1 , 'value')
filesToAccess = fileNames(ind)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by