This question is closed and may reopen in the future if edited.
Hi , I have built a user interface in guide. i wish to allow the user to enter numeric values and set them to some variables that would be available to all functions in the program. to do this i used the text editing option and used the function attached below. i assigned the values to handles and used guidata() at the end
However, this forces me to set the value of Zc every time. i wish to have a default value read and assigned. how can i do that? thanks
function Zc_Callback(hObject, eventdata, handles) % hObject handle to Zc (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.SphereCenterZ=str2double(get(hObject,'String')); % Hints: get(hObject,'String') returns contents of Zc as text % str2double(get(hObject,'String')) returns contents of Zc as a double guidata(hObject,handles); end
% --- Executes during object creation, after setting all properties. function Zc_CreateFcn(hObject, eventdata, handles) % hObject handle to Zc (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 end