List box with strings, Append those strings in the title of the figures when clicking on it.?

Asked by Sabarinathan Vadivelu on 17 Aug 2012
Latest activity Commented on by Sabarinathan Vadivelu on 18 Aug 2012

I have a List box. Which has strings say red, blue, green. An image is also there. when clicking the red, it should appear on the title of the figure, likewise next by clicking blue, it should append with red, likewise green also.

0 Comments

Sabarinathan Vadivelu

Tags

Products

2 Answers

Answer by Image Analyst on 17 Aug 2012
Accepted answer

Get the string property of the listbox to get all the items in the listbox. Get the value property to get which one on selected and use that as an index into the list of all the items. Then use sprintf() to create your string and use title() to display it atop the image.

0 Comments

Image Analyst
Answer by Sean de Wolski on 17 Aug 2012
figure;
imshow('cameraman.tif');
str = {'red','green','blue'};
hL = uicontrol('style','list','string',str,...
  'callback',@(src,evt)title(sprintf('Color is: %s',str{get(src,'value')})));

1 Comment

Sabarinathan Vadivelu on 18 Aug 2012

Actually I need that string selected to be displayed at the top. That is okay. The problem is when I select the next string (say green), It have to be appended with red. Displaying red,green. please rectify the problem.

Sean de Wolski

Contact us