ایران متلب 1- رابط گرافيكي براي كاربر )GUI( GUI menus sliders ) list boxes ( ) pushbuttons - PDF

ایران متلب - رابط گرافيكي براي كاربر )( menus sliders ) list boxes ( ) pushbuttons كي Graphical User Interface ( ) pushbutton MATLAB چگونه كار مي كند - text box menu list togglebutton pushbutton

Please download to get full document.

View again

of 66
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.

Internet & Technology

Publish on:

Views: 8 | Pages: 66

Extension: PDF | Download: 0

ایران متلب - رابط گرافيكي براي كاربر )( menus sliders ) list boxes ( ) pushbuttons كي Graphical User Interface ( ) pushbutton MATLAB چگونه كار مي كند - text box menu list togglebutton pushbutton event driven event event MATLAB ( اجزا (Components) - editbox label pushbutton) list editbox pushbutton slider 2 Graphical User Interface ( ) uncontenxmenu axes اشكال (Figures) 2- figure figure figure figure فراخوان ها (Callbacks) -3 event MATLAB event function 3 Graphical User Interface ( ) Figure toggle button pushbutton text check box radio button list box slider edit box field مشخصات بعضي از عناصر اصلي : uicontrol) : Pushbutton 4 Graphical User Interface ( ) uicontrol) : Toggle button toggle button uicontrol) : Radio button radio button toggle button check box : (uicontrol) : Check box edit box : (uicontrol) : Edit box Callback enter uicontrol) : List box text string 5 Graphical User Interface ( ) uicontrol) : Popupmenu popup slider : (uicontrol) : Slider slider uicontrol) : Frame figure label uicontrol) : Text field text field figure uimenu) : Menu items context uicontextmenu) : Context menu Axes axes) : Axes 6 Graphical User Interface ( ) guide MATLAB -2 ايجاد و نمايش يك properties guide 2 Layout editor guide 7 Graphical User Interface ( ) Menu Editor Tab Order Editor Property Ins p ector Align Objects Object Browser Components Design Area Drag to Resize Design Area guide 2 layout layout editor toolbar layout propertise 8 Graphical User Interface ( ) MATLAB figure guide figure guide Property Inspector MATLAB tag guide figure figure.fig M-File pushbutton pushbutton pushbutton 9 Graphical User Interface ( ) text text pushbutton field 3 field Total Clicks : 0 Figure Text Field Pushb Pushbutton pushbutton 3 guide guide 2 pushbutton Alignment 4 0 Graphical User Interface ( ) guide 4 property toolbar Property Inspector right-click property Inspector Inspect Properties 5 pushbutton property Graphical User Interface ( ) get set Property Inspector property property Inspedtor 5. MyFirstButton Tag Click Here string property Pushbutton string property 2 Graphical User Interface ( ) Tag property Tag click here string. `My First Button` property text field String property text field Tag property text field `My First Tag `Total click:0` String 6 Text` pushbutton property 6 3 Graphical User Interface ( ). textfield property Layout Editor Figure Property Inspector Name property MyFirst MyFirst File Save.fig MyFirst.m MyFirst.fig load M-File M-File 7 MyFirst 4 Graphical User Interface ( ) MYFirstGui MyFirstButton Callback not implemented yet. 7 MyFirstButton 8 guide M-File 5 Graphical User Interface ( ) MyFirst M-File 8 MyFirst MyFirst MyFirst.fig fevel Edit Field MATLAB 6 Graphical User Interface ( ) Tag property MyFirstButton _Callback MyFirstButton_Callback guide M-File ballback MyFirst MATLAB pushbutton MyFirstButton_Callback MyFirst 9 MyFirstButton_Callback String property MyFirstText function MyFirstButton_Callback(hObject, eventdata, handles) %Declare and initialize variable to store the count persistent count 7 Graphical User Interface ( ) if isempty(count) count=0; end %Update count count = count + ; %Create new string str=sprintf('total Clicks : %d',count); %Update the text field set(handles.myfirsttext,'string',str); Original event : Mouse click on button Total Clicks : 0 Push button Button calls MyFirst With Argument MyFirst_Callback MyFirst MyFirst calls subfunction MyFirst_Callback MyFirstButton_Callback Function updates string in MyFirstText Total Clicks : Push button 8 Graphical User Interface ( ) MyFirst 9 MyFirstButton_Callback MyFirst MyFirst count MyFirstButton_Callback textfield count persistent count count count update MyFirstText MyFirst MyFirst MATLAB MyFirstButton_Callback text field MyFirstButton_Callback MyFirst count 0 9 Graphical User Interface ( ) 0-2- نگاهي عميقتر guide MyFirst M_File 8 M-File function varargout varargin varargin varargout MyFirst فراخواني M-File بدون آرگومان 20 Graphical User Interface ( ) nargin MyFirst openfig openfig MyFirst.fig Fig=openfig ( `mfilename`,`reuse`); load mfilename `reuse` `reuse` openfig openfig `new` `new` `reuse` guide openfig MyFirst load Set(fig,'color',get(0,'defaultUicontrolBsckgroundcolor')); MATLAB 2 Graphical User Interface ( ) UNIX handle handles Handles = guihandles(fig); Guidata(fig,handles); handle guihandles Tag MyFirst.m handle handle Handles = guihandles (fig) Handles = Figure MyFirstText: MyFirstButton: text field figure handles guidata pushbutton setappdata 22 Graphical User Interface ( ) handles MyFirst If nargin 0 Varargin{} = fig; end فراخواني M-File با آرگومان MyFirst nargin fevel fevel varagin{3}, varagin{2} varagin{} M-File -2-2 ساختار يك زير تابع Function componenttag_(hobject, eventdata, handles,varargin); componenttag Tag property (parent) handle -hobject MATLAB eventdata 23 Graphical User Interface ( ) handle handles handles varagin figure handles MyFirst text field %Update the text field Set(handles.MyFirstText.'string',str); -2-3 اضافه كردن Application Data به يك شكل handles MATLAB global M-File handles guide guidata guihandles application data 24 Graphical User Interface ( ) count handles handles %Generete a structure of handles to pass to s Handles = guihandles(fig); %Add count to the structure. Handles.count = 0; %Store the structure Guidata(fig,handles); handles count handles guidata handles Function componenttag_(hobject, eventdata, handles,varargin); %Update count Handles.count = handles.count+ %Save the update handles structure Guidata(hObject,handles); 25 Graphical User Interface ( ) %Creat new string Str=sprintf('Total Clicks: %d',handles.count); %Update the text field Set (handles.myfirsttext,'string',str); -2-4 چند تابع مفيد ديگر handle (get object) gcbo handle (get gcbo gcbf findobj figure) gcbf findobj property handle Hndl = Findobj(parent,'property',value); `property` property handle parent `value` 26 Graphical User Interface ( ) `button` Hndl = findobj(gcbf,'tag','button'); Set(Hndl,'string',New text'); property -3 هاي يك شيء property figure property Online Property uicontrol axe property Help Browser uicontrol figure get Property Inspector Property property Property Inspector set property set get 27 Graphical User Interface ( ) -4 اجزاي Text Field( ) Edit Boxes Frames( ) Pushbuttons Toggle Button Chekboxes Radio Bations Popup Menus List Boxes Sliders Property هاي مهم يك شكل color `b` `g` `r` ] 0 [ magenta 0 28 Graphical User Interface ( ) MenuBar `figure` property `none` Name NumberTitle `off` `on` property position `units` y x SelectionType `open` `normal` MATLAB Online Units Tag `pixels` `points` `normalized` `centimeters` Visibe `pixels` `inches` `characters` `off` `on` 29 Graphical User Interface ( ) modal normal Windowstyle. `modal` `normal` مشخصات مهم اشياء uicontrol BackgroundColor `b` `g` `r` [] magenta 0 0 Callback Enable property `on` `off` FontAngle FontName `oblique` `italic` `normal` FontSize points 30 Graphical User Interface ( ) FontWeight `bold` `demi` `normal` `light` ForegroundColor HorizontalAligment. `right` `center` `left` :. value property : Max value property Min handle : Parent `units` Position y x Tag Tooltipstring Units `pixels` `centimeters` `inches` `pixels` `chracters` `normalized` `points` 3 Graphical User Interface ( ) check box toggle button uicontrol value off Max property on radio button property Min property `on` visible. `off` - Text Field ها 4- text field Horizontal text field property Alignment `edit` style property uicontrol text field Layout Editor text field Text field String property 2 Edit Box -4-2 ها 32 Graphical User Interface ( ) edit box Enter edit box edit box `edit` property style uicontrol Layout Editor edit box `EditBox` edit box `TextBox` text field EditBox_Callback edit box edit box handles text field function EditBox_Callback(hObject, eventdata, handles) %Find the value typed into the edit box str = get(handles.editbox,'string'); %Place the value into the text field set (handles.textbox,'string',str); 33 Graphical User Interface ( ) text field edit box 2 edit box 'Hello' 34 Graphical User Interface ( ) test_edit 2 Frame ها Frame radio button 35 Graphical User Interface ( ) `frame` style property uicontrol Layout frame 7 MATLAB Editor frame Panel Frame Pushbutton -4-4 ها pushbutton style uicontrol pushbutton `pushbutton` property pushbutton. Layout Editor pushbutton 0 MyFirst Toggle Button -4-5 ها off on toggle button toggle button max on `value` 0 min off style property uicontrol toggle button 36 Graphical User Interface ( ) `togglebutton`. Layout Editor toggle button `ToggleButton` toggle button 3 `TextBox` textfield togglebutton handles Value property ToggleButton_Callback toggle button text field text field function togglebutton_callback(hobject, eventdata, handles) %Find the state of the toggle button state = get (handles.togglebutton,'value'); %Place the value into the text field if state == 0 set (handles.textbox,'string','off'); else set (handles.textbox,'string','on'); end 37 Graphical User Interface ( ) text field toggle button 3 4 toggle button test_togglebutton 4 togglebutton 38 Graphical User Interface ( ) Checkbox -4-6 ها و Radio button ها toggle button Radio button Checkbox Radio button Checkbox off on toggle button Value off max on property radio button checkbox 0 min 0 style property uicontrol checkbox checkbox `checkbox` radio button Layout Editor `radiobutton` style uicontrol radio button radio Layout Editor button on/off checkbox radio button 39 Graphical User Interface ( ) text field radio button 5 radio button 5 radio button radio button Option3 Option2 Option : radio button function radiobutton_callback(hobject, eventdata, handles) set(handles.label,'string','option '); function radiobutton2_callback(hobject, eventdata, handles) set(handles.label,'string','option 2'); function radiobutton3_callback(hobject, eventdata, handles) set(handles.label,'string','option 3'); 40 Graphical User Interface ( ) radio button text box radio on radio button off button radio button 6 Option 2 test_radiobutton منوهاي Popup popup cell popup `value` Layout Editor popup menu 4 Graphical User Interface ( ) popup 7. Option 2 Option popup text field popup 7 popup function Popup_Callback(hObject, eventdata, handles) %Find the value of the popup menu Value = get(handles.popup,'value'); %Place the value into the text field str = ['Option ' num2str(value) ]; set (handles.label,'string',str); 42 Graphical User Interface ( ) `value` 8 text field Option 4 test_popup 8 ها List Box -4-8 list box scroll bar list box list box Value property style property uicontrol list box 43 Graphical User Interface ( ) listbox list box `listbox`. Layout Editor list box pushbutton SelectionType property `normal` SelectionType `open` SelectionType property property property min max list box 9 option 2 option list box text field pushbutton pushbutton list box 44 Graphical User Interface ( ) list box listbox_ gcbf text list box field function button_callback(hobject, eventdata, handles) %Find the value of the listbox value = get(handles.listbox,'value'); %Update text label str = ['Option ' num2str(value) ]; set (handles.label,'string',str); function listbox_callback(hobject, eventdata, handles) selectiontype=get(gcbo,'selectiontype'); if selectiontype()== 'o' %Find the value of the listbox value = get(handles.listbox,'value'); 45 Graphical User Interface ( ) %Update text label str = ['Option ' num2str(value) ]; set (handles.label,'string',str); end text field pushbutton listbox 9 Button_Callback pushbutton text field list box 20 test_listbox 46 Graphical User Interface ( ) 20 Slider -4-9 test_listbox ها slider bar slider Value property min max style property uicontrol slider Layout slider `slider` Editor text field slider 2 0 Max property slider min property Slider_Callback Slider text field `Value` slider 47 Graphical User Interface ( ) text field slider 2 slider 22 test_slider 22 Dialog Box -5 ها )جعبه هاي محاوره اي( figure dialog box dialog box 48 Graphical User Interface ( ) property modal non-modal modal dialog box dialog box dialog box nonmodal dialog box MATLAB dialog box هاي منتخب : dialog box dialog dialog box errordlg OK dialog box help helpdlg OK inputdlg listdlg 49 Graphical User Interface ( ) dialog box printdlg dialog box questdlg Cancel No Yes dialog box uigetfile dialog box uiputfile dialog box uisetcolor dialog box uisetfont dialog box warndlg OK Warning و Error هاي Dialog Box -5- error dialog box warning dialog box dialog box errordlg(error_string,box_title,create_mode); warningdlg(warning_string,box_title,create_mode); 50 Graphical User Interface ( ) error_string warning_string create_mode dialog box box_title `non-modal` `modal` dialog box modal dialog box 25 errordlg('invalid input value!','error Dialig Box','modal'); error dialog box 25 Input Dialog Box -5-2 ها 5 Graphical User Interface ( ) input dialog box input dialog box answer = inputdlg(prompt) answer = inputdlg(prompt,title) answer = inputdlg(prompt,title,line_no) answer = inputdlg(prompt,title,line_no,defalt_answer) prompt title line_no dialog box default_answer prompt OK answer figure input dialog prompt{}='starting x position:'; prompt{2}='starting y position:'; prompt{3}='width:'; prompt{4}='height:'; title='set Figure Position'; default_ans={'50','50','80','00'}; answer=inputdlg(prompt,title,,default_ans) ; 52 Graphical User Interface ( ) 26 dialog box و input dialog box 26 uisetfile uigetfile هاي Dialog Box -5-3 uisetfile uigetfile dialog box dialog box [filename, pathname]=uigetfile(filter_spec,title); [filename, pathname]=uisetfile(filter_spec,title); 53 Graphical User Interface ( ) filter_spec title `*.mat` `*.m` dialog box filename dialog box Cancel dialog box pathname filename dialog box script file [filename, pathname]=uigetfile('*.mat','load MAT file'); if filename ~= 0 load( [pathname filename]) end mat-file dialog box 27 Windows XP dialog box 27 uigetfile 54 Graphical User Interface ( ) MATLAB Menu ها Menu -6 menu bar MATLAB Context uimenu uimenu uimenu parent property uicontrol Enable Accelerator : uimenu هاي مهم Property CTRl + key Callback 55 Graphical User Interface ( ) `on` property Checked `off` `on` property Enable property `off` `on` property Lable & label property F `&file` ` File ` handle : Parent menu bar Position menu bar `on` Property Seperator `off` `on` Tag `on` Visible 56 Graphical User Interface ( ). `off` uimenu figure 28 b 28 a (a) 57 Graphical User Interface ( ) Figure Ui menu ( M e n u ) Ui menu ( Me nu 2 ) Uimenu ( It e m ) Ui menu ( It e m 2 ) Uimenu ( It e m 3 ) Uimenu ( It e m ) Uimenu ( Sub m e n u It e m ) Uimenu ( Sub m e n u It e m 2 ) (b) (b) (a) Menu Editor MATLAB Menu Editor Property Menu Editor propedit Editor 58 Graphical User Interface ( ) Menu Editor 29 uicontextmenu context context uimenu uicontextmenu مشخه هاي مهم اشياء uicontextmenu context context 59 Graphical User Interface ( ) context Tag context handle : parent context Visible -6- از بين بردن اثر منوهاي پيش فرض MATLAB MenuBar property `none` `figure` none figure Property Inspector -6-2 چگونه منوهاي مورد نظرمان را بسازيم Menu Editor Tag Label 60 Graphical User Interface ( ) uimenu uicontrol MyGui (`MenuItemTag_Callback`, gcbo, [ ], guidata(gcbo)) Tag MyGui. MenuItemTag Property Editor Label Tag Menu Property Editor Callback Property Editor Menu Editor Property Editor 7 Editor MATLAB -6-3 كليدهاي ميانبر و كليدهاي مخفف MATLAB CTRL+Key File/Open o 6 Graphical User Interface ( ) O CTRL File/Open Accelerator property uimenu File 30 Open 30 ALT Edit F ile Graphical User Interface ( ) Exit x ALT+f )&( )&( Label Property 'E&xit' 30 Exit Label property -6-4 ساخت منوهاي Context Context uicontextmenu uicontextmenu (figure) context Menu context context Menu Editor Uicontextmenu context context handle Property set Property Inspector 63 Graphical User Interface ( ) context handle Hcm plot H=plot(x,y); set(h, `UiContextmenu`, Hcm) ; context -7 نكاتي براي خلق هاي كارآمدتر Tool tip tool tips -7- uicontrol tool tip. tooltipstring property Pcode -7-2 MATLAB run-time pcode pcode interpreter MATLAB MATLAB 64 Graphical User Interface ( ) pcode pcode MATLAB pcode pcode pcode MATLAB pcode fun.m fun2.m fun3.m... pcode *.m M-File .p foo.p foo.m M-File P-File P-File MATLAB M-File 65 Graphical User Interface ( ) pcode pcode 66
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks