MATLAB Creating Graphical User Interfaces
(^1) Search and replace all instances that refer to the callback function in your code. (^2) Open the UI in GUIDE and replace al ...
Initialize UI Components in GUIDE Apps In this section... “Opening Function” on page 7-8 “Output Function” on page 7-10 Opening ...
to the opening function. The opening function can take actions with them (for example, setting property values) and also make th ...
% with existing figure properties. See the output of set(figure) for % a list of figure properties. if(nargin > 3) for index ...
Function Naming and Template GUIDE names the output function by appending _OutputFcn to the name of the UI. This is an example o ...
Callbacks for Specific Components Coding the behavior of a UI component involves specific tasks that are unique to the type of c ...
The first line of code, display('Goodbye'), displays 'Goodbye' in the Command Window. The next line gets the UI window using gcf ...
display('Selected'); else display('Not selected'); end The radio button’s Value property matches the Min property when the radio ...
Edit Text Field This code is an example of a callback for an edit text field in GUIDE. Associate this function with the uicontro ...
uicontrol(hObject) return else display(input); end When the end user enters values into the edit text field and presses the Ente ...
function listbox1_CreateFcn(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO) % eventdata reserved - to be de ...
Write the Callback Function This code is an example of a list box callback function in GUIDE. Associate this function with the l ...
% handles empty - handles not created until after all CreateFcns % Hint: popupmenu controls usually have a white background on W ...
function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be ...
Resize the Window and Panel By default, GUIDE UIs cannot be resized, but you can override this behavior by selecting Tools > ...
Do not code callbacks for the individual buttons that are inside a button group. Instead, use the button group’s SelectionChange ...
% -------------------------------------------------------------------- function edit_menu_Callback(hObject, eventdata, handles) ...
% hObject handle to copy_menu_item (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles struc ...
if strcmp(get(hObject,'Checked'),'on') set(hObject,'Checked','off'); else set(hObject,'Checked','on'); end The strcmp function c ...
Sums all the selected values and displays the result in the Command Window. This code is an example of the table callback func ...
«
6
7
8
9
10
11
12
13
14
15
»
Free download pdf