我正在开发一个计算器,使用MATLAB的GUIDE从朱利安时间转换为标准IRIG时间。当启动时,计算器在一个方向上运行良好,或者在另一个方向上运行,但不知何故,在同一会话中来回运行时,有些东西被删除了。我只使用了两个按钮,这是这两个按钮回调的代码:
% --- Executes on button press in convertjulian.
function convertjulian_Callback(hObject, eventdata, handles)
% hObject handle to convertjulian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
value = handles.isec;
day = floor(value/86400);
remainder = (value/86400 - day)*86400;
hour = floor(remainder/3600);
remainder = (remainder/3600 - hour)*3600;
min = floor(remainder/60);
sec = (remainder/60 - min)*60;
set(handles.jday,'String',day);
set(handles.jhour,'String',hour);
set(handles.jmin,'String',min);
set(handles.jsec,'String',sec);
这是另一个回调:
% --- Executes on button press in convertirig.
function convertirig_Callback(hObject, eventdata, handles)
% hObject handle to convertirig (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
seconds=handles.jday*86400+handles.jhour*3600+handles.jmin*60+handles.jsec;
set(handles.isec,'String',sprintf('%0.3f',seconds));
这是我在MATLAB中运行它时得到的错误:
使用handle.handle/set出错对象无效或已删除。
timeeconversion错误>convertjulian_Callback(第124行)集(handles.jday,"字符串",一天),
gui_mainfcn中的错误(第96行)函数宏指令(变长度输入宗量{:});
时间转换错误(第42行)gui_mainfcn (gui_State变长度输入宗量{:});
在@(hObject,eventdata) timeeconversion ('convertjulian_Callback',hObject,eventdata,guidata(hObject))中出错
计算uicontrol Callback时出错
将句柄视为数值。要从handles.isec
获取值,您可以使用:
value = str2double(get(handles.isec, 'String'));
所有的'j'句柄都是相似的。