Your question is not clear, what do you mean by: i wish to have a default value read and assigned ?
Info
此问题已关闭。 请重新打开它进行编辑或回答。
data transfer in guide
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!