How can I modify the below code such that when clicking on a string from the list box, when clicking on another string it should append to the previously clicked string.

조회 수: 1 (최근 30일)
How can I modify the below code such that when clicking on a string from the list box, when clicking on another string it should append to the previously clicked string.
function [] = newnew()
S.fh = figure('position',[400 450 500 200],...
'name','GUI_pop_to_list');
S.pp = uicontrol('style','list',...
'min',0,'max',2,...
'position',[20 90 190 100],...
'string',{'building';'grass';'tree';'cow';'boat';'sheep';'sky';'mountain'});
S.ls = uicontrol();
S.pb = uicontrol('style','push',...
'position',[20 20 190 40],...
'string','Transfer',...
'callback',{@pb_call,S});
uicontrol(S.pp)
function [] = pb_call(varargin)
S = varargin{3};
E = get(S.pp,{'string','value'});
STR = get(S.ls,'string');
set(S.ls,'string',[STR;subplot(1,2,2);imshow('attachment.jpg');title(E{1}(E{2}))])

채택된 답변

Image Analyst
Image Analyst 2012년 8월 17일
Instead of this mess:
set(S.ls,'string',[STR;subplot(1,2,2);imshow('attachment.jpg');title(E{1}(E{2}))])
why not make up your string with sprintf(),
myString = sprintf(........);
set(S.ls, 'String', myString);
I have no idea why you're trying to do an imshow() and a call to title() inside a call to send a string to a static text label. That just doesn't make sense at all.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by