Environmental Engineering Reference
In-Depth Information
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
val = get(hObject,'Value');
switch val
case 1
msgbox('E. Holzbecher, WIAS, Mohrenstr. 39, 10117 Berlin,...
GERMANY, E-mail: holzbecher@wias-berlin.de','Info','none');
web http://www.igb-...
berlin.de/abt1/mitarbeiter/holzbecher/index_e.shtml;
uiwait;
case 2
msgbox('Environmental Modeling using MATLAB, Springer...
Publ.','Info','none');
case 3
msgbox('Springer Publ., Heidelberg','Info','none');
web www.springer.com;
uiwait;
case 4
msgbox('MATLAB, MathWorks Inc, see: www.mathworks.com',...
'Info','none');
web www.mathworks.com;
uiwait;
end
The 'callback' function is reached when the user has clicked on a menu entry of
the pop-up menu. In the example, the pop-up menu has four entries: 'Author',
'Book', 'Publisher' and 'Software'. During the execution of the program, the
menu entry, which is selected by the user, is obtained by the command get
(hObject,'Value') . The returned variable is an integer between 1 and 4, by
which the selection is uniquely determined. In the listing the current value is stored
in variable val .
It is convenient to use the switch keyword for the val variable in order to jump
to different command blocks. If the value is 1, a message box opens with informa-
tion about the author. The corresponding MATLAB
command is: msgbox . Addi-
tionally, using the web command, a browser opens with the personal site of the
author. The uiwait command makes the process wait until the user clicks at the
closure button.
The other cases are handled in exactly the same way; there are other message
texts and other web-sites.
®
The code is included in the accompanying software under the name
'transport.m'
As an example for a more elaborated graphical user interface, the 'pplane7.m'
file for processing ordinary differential equations was already mentioned in
Chap. 19; see also: Polking ( 2004 ). Another example implementation for
Search WWH ::




Custom Search