0% found this document useful (0 votes)
22 views

GUI Axes

This document provides examples of using axes objects in MATLAB GUI development. It shows how to design a GUI with one axes and use the imshow function to display an image array in the axes. It also gives a quiz to modify the example

Uploaded by

Sama Talee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

GUI Axes

This document provides examples of using axes objects in MATLAB GUI development. It shows how to design a GUI with one axes and use the imshow function to display an image array in the axes. It also gives a quiz to modify the example

Uploaded by

Sama Talee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

GUI Axes

creates an axes graphics object in the current figure using default property
values. axes for creating graphics objects. MATLAB uses default values for any
properties that you do not explicitly define as arguments. the basic purpose of an axes
object is to provide a coordinate system for plotted data, axes properties provide
control over the way MATLAB displays data. axes(h) makes existing axes h the
current axes and brings the figure containing it into focus. It alsomakes h the first
axes listed in the figure and sets the figure as CurrentAxes to h. The current axes is
the target, that draw image, line, rectangle, surface, and text graphics objects.

EX: design GUI (img.fig) as shown:

function pushbutton1_Callback(hObject,eventdata, handles)


axes(handles.a);

imshow([1 1 1 1;0 0 0 0;1 1 1 1]);


end
Quiz: modefiy the above function to plot coordenates (2,4) ,
(4,6) , (3,1) and show it in axes a
How to close running GUI
1- To exit (close) from GUI under run, you can put in the layout new bushbutton
its string(Exit/Quit/Cancul)then in the bushbutton_callback function,write close( )
2- To close running GUI by press X icon in the upper right corner of GUI figure.
How to call another GUI from current GUI
To run (call ) another GUI (ex: ader.fig/ader.m) from the current GUI under run,
you can put in its layout new bushbutton its string indicates to the meaning of (ex:
ader), then in the bushbutton _callback function,write :
1- write file name of GUI (ex: ader ; ).
2- Or : use instruction: openfig( ' ader.fig ' );
Radio Button
You can use only one radio button as switch (on/off); when 'on' do task,when off do
another task, so tasks code will put it in callbacks for the individual buttons. you can
use many radio button as group so you must included them inside button group
object, uibuttongroup, Create container object to exclusively manage radio buttons.
When programming a button group, you do not code callbacks for the individual
buttons; instead, use its SelectionChangeFcn callback to manage responses to
selections
EX: use one radio button: when 'on' show 'cameraman.tif '/ 'off ' show 'trees.tif '

function rb_Callback(hObject, eventdata, handles)


axes(handles.axes1);
if get(hObject,'Value') == 1
imshow(imread(' cameraman.tif '));
else
imshow(imread(' trees.tif '));
end
EX: design GUI for 4 buttons in one group :

function p_Callback(hObject, eventdata, handles)

h1=findobj('Tag','a');

x=str2double(get(h1,'string'))

h2=findobj('Tag','b');

y=str2double(get(h2,'string'));

switch get(get(handles.up1,'SelectedObject'),'Tag')

case 'rb1'
z=num2str(x+y);
case 'rb2'
z=num2str(x-y);
case 'rb3'
z=num2str(x*y);
case 'rb4'
z=num2str(x/y);
end
h3=findobj('tag','c')

set(h3,'string',z);
HOW to Call SIMULation Model (ex: simif.xls)from GUI
open_system('simif.slx'); % load system 'simif.xls' and show the model on screen

Quiz: design GUI with 2 radiobutton : if both are on then show trees.tif image, if one
of them on, show cameraman.tif, if both are off show rice.png image.
1- For this quiz: Need radio-bottun group or isolated radio bottun?
2- can use: 1 axes , 2 axes, 3 axes: (what is your opinion about the best of them ?)
Quiz: design GUI with one edit_text for enter image file by keyboard. 3 radiobottun
(text: rotate -90,rotate +90,unrotated) and one axes for show the image
according to the radio selected option.
Quiz:design 2 GUI: 1st GUI (gui_fct.fig) :has 2 push bottun (! , exit) and 2 edit_text
for enter value by key board then display its factorial, 2nd GUI has 3 push
bottun with tag (Drow, factorial, Exit), and 2 axes with tag (a1,a2), when:
1- press 1st push button (drow), the 1st axes shows 'cameraman.tif ',2nd axes:'trees.tif '
2- press 2nd button (factoreal) to call GUI ( gui_f.fig ) in the 1st page.
3- press 3rd button (Exit) will stop the running.

You might also like