º¥ý¡A§ÚÌ¥ý§ïÅÜ GUIDE ±ª©ªº¤j¤p¡]¥i¸g¥Ñ©ì©ñ±ª©¥k¤U¨¤ªº¶ÂÂI¨Ó¹F¦¨¡^¡A¨Ã¦b±ª©¤W©ñ¸m¨âÓ±±¨îª«¥ó¡A¤@Ó¬O¡u©ÔÅQ¡v¡]Slider¡^¡A¥t¤@Ó¬O¡u¥i½s¿è¤å¦rÄæ¦ì¡v¡]Edit Text¡^¡A¦p¤U¡G
±µµÛ¡A§ÚÌ¥i¥H¨Ï¥Î·Æ¹«¥kÁä¨ÓÂI¿ï¥ô¤@Ó UI ±±¨îª«¥ó¡A¨Ã¿ï¨ú¡uInspect Properties¡v¡A¥H§ïÅܨä©Ê½è¡C¥H¤W±ªº©ÔÅQ¬°¨Ò¡A¥H·Æ¹«¥kÁäÂI¿ï«á¡A¿ï¨ú¡uInspect Properties¡v¡A§Y¥i¶}±Ò¡u©Ê½èÀ˵ø¾¹¡v¡]Property Inspector¡^¡A¨ä¥~Æ[¦p¤U¡G
¦b¦¹©Ê½èÀ˵ø¾¹¤¤¡A¥ªÃä¬Oª«¥óªº©Ê½è¡A¥kÃä«h¬O¦¹©Ê½è©Ò¹ïÀ³ªºÈ¡A§ÚÌ¥i¥HÂI¿ï¥kÃä¨Ó§ïÅܳo¨ÇÈ¡C§Ú̺¥ýn°µªº¨Æ¡A´N¬O³]©w¥Ø«e±ªO¤Wªº¨âÓª«¥óªº¥N¸¹¡A«áÄò¹ï¦¹ª«¥óªº³B²z¡A§Ú̳£·|®Ú¾Ú¦¹¥N¸¹¨Ó¶i¦æ¡C¸g¥Ñ¡u©Ê½èÀ˵ø¾¹¡v¡A§ÚÌ¥i¥H¶i¦æ¦p¤U¡G
- ±N©ÔÅQªº Tag ©Ê½è§ï¦¨¡umySlider¡v¡A¦¹§Y¬O©ÔÅQª«¥óªº¥N¸¹¡C
- ±N¤å¦rÄæ¦ìªº Tag ³]©w¦¨¡umyText¡v¡A¦¹§Y¬O¤å¦rÄæ¦ìª«¥óªº¥N¸¹¡C
§¹¦¨ª«¥ó¥N¸¹ªº³]©w«á¡A§ÚÌ´N¥i¥H³]©wª«¥óªº¤ÏÀ³©R¥O¡C§Ú̧Ʊæ³o¨Ç¤ÏÀ³©R¥O¯à°÷¨Ï³oÓ GUI À³¥Îµ{¦¡¹F¨ì¤U¦C¥\¯à¡G
- ·í¨Ï¥ÎªÌ©ì©ñ©ÔÅQ®É¡A¯à±N©ÔÅQªº¦ì¸m¡]¹w³]ȬO¤¶©ó 0 ©M 1 ¤§¶¡¡^Åã¥Ü¦b¤å¦rÄæ¦ì¡C
- ¦ý¤å¦rÄæ¦ìȳQ§ïÅܮɡA©ÔÅQªº¦ì¸m¯à°÷ÀH¤§§ïÅÜ¡C
¦b GUIDE ªºÀô¹Ò¤U¡A¤@Óª«¥óªº¤ÏÀ³©R¥O³£¬O¥Ñ¤@Ó¯S©wªº¨ç¦¡¨Ó§¹¦¨¡A³oӨ禡´NºÙ¬°¤ÏÀ³¨ç¦¡¡A¦Ó¨ç¦¡¦WºÙ´N¬O¡uª«¥ó¥N¸¹_Callback¡v¡C
º¥ý¡A§ÚÌ¥H·Æ¹«¥kÁäÂI¿ï©ÔÅQ¡A¨Ã¿ï¨ú¡uView Callbacks/Callback¡v¡A§Y¥i¶}±Ò MATLAB µ{¦¡½s¿è¾¹¡C¡]¦pªG§A©|¥¼¦sÀÉ¡AMATLAB ·|n¨D§A¥ý¦sÀÉ¡A¤~¯àÄ~Äò¡C§A¥i¥H¸g¥Ñ GUIDE ¥Dµe±±NÀÉ®×Àx¦s¦¨ myGui01.fig¡A¤§«á©Ò¦³¬ÛÃöµ{¦¡½X§Y·|³QÀx¦s¨ì myGui01.m¡C¡^¦¹µ{¦¡½s¿è¾¹·|Åã¥Ü¤ÏÀ³©R¥O¥²¶·¥[¤Jªº¦ì¸m¡A¨Ì¥»¨Ò¦Ó¨¥¡A©ÔÅQªº Tag ¬O mySlider¡A©Ò¥H¨ä¤ÏÀ³¨ç¦¡¬O mySlider_Callback()¡A©Ò¥[¶i¥hªº¨â¦C±Ôz¦p¤U¡G
position = num2str(get(handles.mySlider, 'Value')); set(handles.myText, 'String', position); ¨ä¤¤²Ä¤@¦C±Ôz§ì¥X©ÔÅQªº¦ì¸m¡A¨ÃÂন¼ÆÈ¡A²Ä¤G¦C«h±N¦¹¼Æȳ]©w¬°¤å¦rÄæ¦ìªºÅã¥Ü¤å¦r¡C¥[¤Jªº¦ì¸m¦p¤U©Ò¥Ü¡G
¨Ï¥Î¬Û¦Pªº¤è¦¡¡A§Ṳ́]¥i¥H¥[¤J¤å¦rÄæ¦ìªº¤ÏÀ³©R¥O¡A¨ä¤ÏÀ³¨ç¦¡¬O myText_Callback()¡A©Ò¥[¶i¥hªº¨â¦C±Ôz¦p¤U
value = str2double(get(handles.myText, 'String')); set(handles.mySlider, 'Value', value); ¨ä¤¤²Ä¤@¦C¬O§ì¥X¤å¦rÄæ¦ìªºÅã¥Ü¤å¦r¡AµM«áÂন¼ÆÈ¡AµM«á¦b²Ä¤G¦C±N©ÔÅQªº¦ì¸m³]©w¦¨¦¹¼ÆÈ¡C¥[¤Jªº¦ì¸m¦p¤U©Ò¥Ü¡G
¥[¤J³o¨Ç¤ÏÀ³©R¥O«á¡A§Y¥iÀx¦sÀɮרÃÃö³¬ MATLAB ½s¿è¾¹¡AµM«á«ö¤U GUIDE ±ª©ªº¤u¨ã¦Cªº¤T¨¤§Î«ö¶s¡A§Y¥i¶}±Ò§ÚÌ©Ò³]pªº GUI ¤¶±¦p¤U¡G
§A¥i¥Hª½±µ²¾°Ê©ÔÅQ¡A¨ä¦ì¸m´N·|Åã¥Ü¦b¤å¦rÄæ¦ì¤º¡F§A¤]¥i¥Hקï¤å¦rÄæ¦ìªºÈ¡A¨Ó«ü©w©ÔÅQªº¦ì¸m¡C
¦pªG§A¤w¸g§¹¦¨¾ãÅé³]p¬yµ{¡A¦¹®É¥i¥HÃö³¬ GUIDE ¥Dµe±¡C¤§«á¥u»Ý¦b MATLAB ¿é¤J myGui01¡A§Y¥i¶}±Ò©Ò³]pªº GUI µ{¦¡µe±¡CYÁÙ»Ýn¶i¦æ GUI µ{¦¡ªº×§ï¡A¥u»Ý¦b MATLAB ¿é¤J guide myGuide01¡A§Y¥i¶}±Ò GUIDE ¥Dµe±¨ÃÄ~Äò¶i¦æ GUI µ{¦¡³]p¡A¨Ò¦p¥[¤J·sªº±±¨îª«¥ó¨Ã©w¸q¬ÛÃö¤ÏÀ³©R¥Oµ¥¡C
¤Wz½d¨Ò¤w¸g¦¬¿ý¦b¥»®Ñ½d¨Ò¥Ø¿ý¤¤ªº gui01.m ©M gui01.fig¡C
±q³oÓ½d¨Ò¤¤§ÚÌ¥i¥Hª¾¹D¡A¦b³]p¤ÏÀ³©R¥O®É¡A³Ì«nªº¨Æ¡A´N¬On¯àÅý¤£¦Pªº UI ±±¨îª«¥ó³£¯à¦s¨ú¨ä¥Lª«¥ó¥H¤Î¬ÛÃö¸ê®Æ¡A¦]¬°¨C¤@Ó UI ±±¨îª«¥óªº¤ÏÀ³©R¥O³£¬O¥H¨ç¦¡ªº«¬¦¡¨Ó¶i¦æ¡A¦]¦¹ GUIDE ¦b¨C¤@Ó¤ÏÀ³¨ç¦¡¤º´£¨Ñ¤F¤@Óµ²ºcÅÜ¼Æ handles¡A¥H«K´£¨Ñ¸ê®Æªº¦@³q¡A¥i¹F¨ì¤U¦C¨â¶µ¥\¯à¡G
- ¥i¥H¸g¥Ñ handles ¨Ó¦s©ñ©Î¨ú¥Î¦@³qªº¸ê®Æ¡C
- ¥i¥H¸g¥Ñ handles ¨Ó¨ú±o¨C¤@Ó UI ±±¨îª«¥óªº©Ê½è¡C
¨Ò¦p¡AYn¦b¬Y¤@Ó±±¨îª«¥óªº¤ÏÀ³¨ç¦¡¤º¦s©ñÅÜ¼Æ A¡A¥i¥H¥[¤J¤U¦C±Ôz¡G
handles.myData = A; % ±NÅÜ¼Æ A ¦s©ñ¦b handles ªº myData Äæ¦ì guidata(hObject, handles) % ±N·sªº handles ¦s¦^¾ãÓ GUI ¤¶± ¦pªGn¦b¥t¤@Ó±±¨îª«¥óªº¤ÏÀ³¨ç¦¡¸Ì±¨Ï¥ÎÅÜ¼Æ A¡A¥un¥[¤J¤U¦C±Ôz§Y¥i¡G
A = handles.myData; ¥t¥~¡Ahandles ¥»¨¤]¥]§t¤F¦P¤@Ó GUI ¤¶±¤Uªº©Ò¦³±±¨îª«¥ó¡A¥H¤W¤@¸`ªº½d¨Ò¨Ó»¡¡A§ÚÌ©w¸q¤F¨âÓ±±¨îª«¥óªº Tag¡A¦]¦¹§A¥i¥H¦b¥ô¤@Ó¤ÏÀ³¨ç¦¡¤º¨ú¥Î¨C¤@Ó±±¨îª«¥ó¡A¦p¤U¡G
handles.mySlider¡G©ÔÅQª«¥ó handles.myText¡G¤å¦rÄæ¦ìª«¥ó ¦pªG¾ãÓ GUI ªº¦WºÙ¬O myGUI¡A¨º»ò handles.myGUI ´N¬O«ü¨ì¾ãÓ GUI ªº¹Ï§Î¡A¦]¦¹YnÃö³¬¦¹µøµ¡¡A¤]¥i¥H¨Ï¥Î¤U¦C±Ôz¡G
delete(handles.myGUI)
MATLABµ{¦¡³]p¡G¤Jªù½g