Environmental Engineering Reference
In-Depth Information
Some explanations concerning the functions are given in the comments. Most
sub-functions are of the following types:
function D_edit_Callback(hObject, eventdata, handles)
% hObject handle to D_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of D_edit as text
% str2double(get(hObject,'String')) returns contents of
% D_edit as a double
% -- Executes during object creation, after setting all properties.
function D_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to D_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
% called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
There is one 'callback' function and one 'create' function. The reader may verify
that there are these two sub-functions for each element of the GUI window. With
the functions the functionality of the GUI is created. The 'callback' function is
called every time when the element is selected during the execution of the program.
In the example command sequence the function listings are empty, aside from an
adjustment concerning the background color ( get and set commands). I.e. the
standard functionality of the GUI element is performed, with which the user is not
really concerned here.
In the current example there is only one part of the program where the user has to
add some functionality. That concerns the 'Run' -button. When that button is
pressed, several tasks have to be performed in order to draw a picture of the
concentration profiles on the screen. The corresponding commands have to be
added to the runbutton_Callback function, which is executed after pressing the
run-button. Here we add the following list:
% --- Executes on button press in runbutton.
function runbutton_Callback(hObject, eventdata, handles)
% hObject handle to runbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get user input from GUI
D = str2double(get(handles.D_edit,'String'));
v = str2double(get(handles.v_edit,'String'));
R = str2double(get(handles.R_edit,'String'));
lambda = str2double(get(handles.lambda_edit,'String'));
T = str2double(get(handles.T_edit,'String'));
L = str2double(get(handles.L_edit,'String'));
Search WWH ::




Custom Search