文本框edit_H
.M文件中有如下代码:
function edit_H_CreateFcn(hObject, eventdata, handles)%创建
% hObject handle to edit_H (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_H_Callback(hObject, eventdata, handles)%输入的时候的回调函数
% hObject handle to edit_H (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 edit_H as text
% str2double(get(hObject,'String')) returns contents of edit_H as a double
edit_H = str2double(get(hObject, 'String'));
if isnan(edit_H)
set(hObject, 'String', 0);
errordlg('输入必须是数字','Error');
end
data = getappdata(gcbf, 'metricdata');
data.edit_H = edit_H;
setappdata(gcbf, 'metricdata', data); 写好后数据保存在:data.edit_H |