Matlab °æ (¾«»ªÇø)
·¢ÐÅÈË: seesea (Âí»¢Ñ§¾¿), ÐÅÇø: Matlab
±ê Ìâ: [ºÏ¼¯]GUIµÄcallbackÎÊÌâ
·¢ÐÅÕ¾: ¹þ¹¤´ó×϶¡Ïã (2002Äê12ÔÂ10ÈÕ20:46:04 ÐÇÆÚ¶þ), Õ¾ÄÚÐżþ
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
september (С¶¬¹Ï) ÓÚ 2000Äê09ÔÂ12ÈÕ07:40:50 ÐÇÆÚ¶þ ˵µÀ:
Hl_Create = uicontrol('Parent',Hf_Mesh, ...
'Callback','MyValue = eval(get(Hl_Create,''Value''))',...
'Style','listbox');
ÉÏÊöÓï¾äÊÇ´´½¨Ò»¸ö Listbox , ÎÒÏëµ±Óû§¸Ä±ä listbox Ñ¡ÔñÏî
ʱ, Äܹ»ÖªµÀÓû§¾¿¾¹Ñ¡ÁËÄÄÒ»¸ö.
µ¥²½µ÷ÊÔʱ, ÔËÐе½Õâ¾ä, ¸ø³öÌáʾ˵:
K» ??? Undefined function or variable 'Hl_Create'.
ÕâÊÇÔõô»ØÊÂ?
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
candle (Âí×ßÈÕ) ÓÚ 2000Äê09ÔÂ12ÈÕ10:42:18 ÐÇÆÚ¶þ ˵µÀ:
ÕâÑùºÃÏñ²»Ðаɡ£
ÔÚÕâ¸öÓï¾äûÓÐÖ´ÐÐÍêʱ£¬ÄǸö±äÁ¿ÊDz»»áÓж¨ÒåµÄ¡£
ËùÒÔ£¬Õâʱ£¬ÄãÐèÒª½«callback¶¨Òå³ÉÒ»¸öº¯Êý¡£
È»ºó£¬°ÑHl_Create¶¨Òå³Égloble¡£
ÔÚº¯ÊýÖÐʵÏÖ¹¦ÄÜ¡£
¡¾ ÔÚ september (С¶¬¹Ï) µÄ´ó×÷ÖÐÌáµ½: ¡¿
: Hl_Create = uicontrol('Parent',Hf_Mesh, ...
: 'Callback','MyValue = eval(get(Hl_Create,''Value''))',...
: 'Style','listbox');
: ÉÏÊöÓï¾äÊÇ´´½¨Ò»¸ö Listbox , ÎÒÏëµ±Óû§¸Ä±ä listbox Ñ¡ÔñÏî
: ʱ, Äܹ»ÖªµÀÓû§¾¿¾¹Ñ¡ÁËÄÄÒ»¸ö.
: µ¥²½µ÷ÊÔʱ, ÔËÐе½Õâ¾ä, ¸ø³öÌáʾ˵:
: K» ??? Undefined function or variable 'Hl_Create'.
: ÕâÊÇÔõô»ØÊÂ?
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
september (С¶¬¹Ï) ÓÚ 2000Äê09ÔÂ12ÈÕ11:04:38 ÐÇÆÚ¶þ ˵µÀ:
¡¾ ÔÚ candle (Âí×ßÈÕ) µÄ´ó×÷ÖÐÌáµ½: ¡¿
: ÕâÑùºÃÏñ²»Ðаɡ£
: ÔÚÕâ¸öÓï¾äûÓÐÖ´ÐÐÍêʱ£¬ÄǸö±äÁ¿ÊDz»»áÓж¨ÒåµÄ¡£
: ËùÒÔ£¬Õâʱ£¬ÄãÐèÒª½«callback¶¨Òå³ÉÒ»¸öº¯Êý¡£
: È»ºó£¬°ÑHl_Create¶¨Òå³Égloble¡£
: ÔÚº¯ÊýÖÐʵÏÖ¹¦ÄÜ¡£
ÎÒÔÚ Callback ÓøÄÓÃÁË findobj
tempHandle = findobj('Tag','MyList');
ÏÖÔÚÎҸоõÔÚ Callback ÓõıäÁ¿ºÍ Matlab ÖÐÔËÐеÄ
±äÁ¿ºÃÏñ²»Ò»Ñù.
ÎÒµÄÒâ˼ÊÇ Callback Öж¨ÒåµÄ±äÁ¿×÷Ó÷¶Î§½öÏÞÓÚ
Callback. ¶øÇÒËüÎÞ·¨·ÃÎÊÎÒµÄ global ±äÁ¿
¾Ù¸öÀý×Ó°É
function MyFunction
global a
.......
a = 1:4;
Hl_Create = uicontrol('Parent',Hf_Mesh, ...
'Callback','MyValue = a(2)',...
'Style','listbox');
µ«ÊÇÌáʾ˵䶨Òå±äÁ¿ a
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
september (С¶¬¹Ï) ÓÚ 2000Äê09ÔÂ12ÈÕ12:59:07 ÐÇÆÚ¶þ ˵µÀ:
¡¾ ÔÚ september (С¶¬¹Ï) µÄ´ó×÷ÖÐÌáµ½: ¡¿
: Hl_Create = uicontrol('Parent',Hf_Mesh, ...
: 'Callback','MyValue = eval(get(Hl_Create,''Value''))',...
: 'Style','listbox');
: ÉÏÊöÓï¾äÊÇ´´½¨Ò»¸ö Listbox , ÎÒÏëµ±Óû§¸Ä±ä listbox Ñ¡ÔñÏî
: ʱ, Äܹ»ÖªµÀÓû§¾¿¾¹Ñ¡ÁËÄÄÒ»¸ö.
: µ¥²½µ÷ÊÔʱ, ÔËÐе½Õâ¾ä, ¸ø³öÌáʾ˵:
: K» ??? Undefined function or variable 'Hl_Create'.
: ÕâÊÇÔõô»ØÊÂ?
ÖÕÓÚµ÷ÊÔͨ¹ýÁË.
´°ÌåÉÏÓÐÁ½¸ö¿Ø¼þ, 1. ListBox 2. PushButton
Listbox ÖÐÓÐÑ¡ÔñÏî,¿ØÖÆÎÒ»µÄͼÐÎ
PushButton ¿ªÊ¼»æ».
ÎÒ°´ÕÕÊéÉÏдµÄ(ÈçÉÏ)ÎÞ·¨Í¨¹ý, ÔÒòÊÇ Matlab °Ñ Callback µ±×÷Ò»¸ö
×Ö·û´®, Ë͵½ workspace, È»ºóͨ¹ý Eval ½âÊÍÖ´ÐÐ. Õâʱ Hl_Create
±äÁ¿·¶Î§½öÏÞÓÚ±¾ function(²»ÖªµÀ˵²»ËµµÄͨ).
½â¾ö°ì·¨:
ÓÃ findobj.
ÀýÈçÔÚ Pushbutton µÄ Callback ÖпÉÒÔÕâôд
ListHandle = findobj('Style','listbox'); % »ñµÃÁË Listbox µÄ¾ä±ú
ListItems = get(ListHandle,'String'); % »ñµÃ Listbox µÄËùÓÐÑ¡ÔñÏî
ListIndex = get(ListHandle,'Value'); % »ñµÃ Listbox Ñ¡ÖÐÏîµÄÐòºÅ
MyValue = ListItems(ListIndex,:); % »ñµÃ Listbox Óû§Ñ¡ÖÐÏî
MyValue = str2num(MyValue); % ½«Æäת»»³É number
.... % ÏàÓ¦µÄÆäËü²Ù×÷
Õû¸ö¹ý³Ì¾ÍÊÇÕâÑùµÄ.
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
september (С¶¬¹Ï) ÓÚ 2000Äê09ÔÂ12ÈÕ15:42:16 ÐÇÆÚ¶þ ˵µÀ:
¡¾ ÔÚ september (С¶¬¹Ï) µÄ´ó×÷ÖÐÌáµ½: ¡¿
: Hl_Create = uicontrol('Parent',Hf_Mesh, ...
: 'Callback','MyValue = eval(get(Hl_Create,''Value''))',...
: 'Style','listbox');
: ÉÏÊöÓï¾äÊÇ´´½¨Ò»¸ö Listbox , ÎÒÏëµ±Óû§¸Ä±ä listbox Ñ¡ÔñÏî
: ʱ, Äܹ»ÖªµÀÓû§¾¿¾¹Ñ¡ÁËÄÄÒ»¸ö.
: µ¥²½µ÷ÊÔʱ, ÔËÐе½Õâ¾ä, ¸ø³öÌáʾ˵:
: K» ??? Undefined function or variable 'Hl_Create'.
: ÕâÊÇÔõô»ØÊÂ?
»¹ÓÐÒ»¸ö½â¾ö°ì·¨, ÎҲŷ¢ÏÖµÄ.
ÎÒµÄÕû¸ö½çÃæÊÇд³ÉÁËÒ»¸ö´ó function,
function MyFigure
Æäʵд³ÉÒ»¸ö M Îļþ¾Í¿ÉÒÔÁË, ÊéÉϸøµÄ
Àý×ÓÒ²¶¼¿ÉÓÃ.
·¢ÏÖ×ÜÊǺÜСµÄÎÊÌâÐèÒªÏûºÄ´óÁ¿µÄʱ¼äÀ´½â¾ö.
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
Ò³ÃæÖ´ÐÐʱ¼ä£º3.479ºÁÃë