Sunteți pe pagina 1din 13

Graphic User Interface In MATLAB

GUI
A graphical user interface (GUI) is a user interface built with graphical objects -- the components of the GUI -such as buttons, text fields, sliders, and menus.

Visualization in Matlab consists of Figures Type figure on the command prompt All figures have a variable ,that is, a figure handler , that keeps tab of the state of the GUI Type h=figure Prompt h;h=1 H is the graphics handle of fig

Object types
The object types in MATLAB are

Set command is used to set the property of a figure.Type H1=figure H2 figure Set(gcf,Color,Red) Gcf stands for get handle to graphics figure

Property and Plot editor


Propedit(gcf) Propedit(gca) get handle to current axis Plotedit() is a toggling function

GUIDE
GUI development Environment Type GUIDE at the command prompt You can select between blank GUI or some Template GUIs and edit the m code or access the objects in the GUI with functions GUI editor includes Object Browser,property inspector and m file editor

GUIDE manipulates graphics objects The Control panel has GUI elements like slider,pushbutton

GUI Roadmap
For whatever task a GUI is required,define that task Draw the GUI using the GUI editor Run and test the figure Using GUIDE append code for function callback like mouse click or an event Test the code

GUI components
figure('MenuBar','none','Name','Gui02',' NumberTitle','off','Position',[200,200,100 ,140]); uicontrol('Style','PushButton','String','Pu sh','Position',[20,100,60,20], 'CallBack',@PushButtonPressed);

Pushbutton and close


uicontrol('Style','PushButton','String','Close','P osition',[20,20,60,20],'CallBack','close'); function PushButtonPressed(h, eventdata) disp('You are pressed a push button'); make the whole file as a function

editbox
Edit=uicontrol('Style','Edit','String',50','P osition',[20,20,100,20],'CallBack', @EditCallBack,'HorizontalAlignment','lef t');

menu
Fig=figure('MenuBar','none','Name','Gui08','N umberTitle','off'); m = uimenu('Label','&File'); uimenu(m,'Label','New','Callback','gui08'); uimenu(m,'Label','NewFigure','Callback','figur e'); uimenu(m,'Label','Quit','Callback','close);

S-ar putea să vă placă și