Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

data transfer in guide

1 vue (au cours des 30 derniers jours)
Itzik Ben Shabat
Itzik Ben Shabat le 13 Jan 2013
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
  1 commentaire
Azzi Abdelmalek
Azzi Abdelmalek le 13 Jan 2013
Your question is not clear, what do you mean by: i wish to have a default value read and assigned ?

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by