到目前为止,只是说我有一个GUI和uicontrol列表,其中有一个按钮,可以启动计算过程。在按钮中,回调函数如下所示:
% --- Executes on button press in mulai.
function mulai_Callback(hObject, eventdata, handles)
% hObject handle to mulai (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%--give the program "Working" status
set(handles.status,'String','Working');
%--empty some edit text
set(handles.misklasifikasi,'String','');
set(handles.nilaiakurasi,'String','');
set(handles.nilaiwaktu,'String','');
%--Some computation process
%--Giving the result
set(handles.misklasifikasi,'String',misklasifikasi);
set(handles.nilaiakurasi,'String',sprintf('%g%% ',akurasi));
set(handles.nilaiwaktu,'String',sprintf('%g detik ',waktu));
%--give the program ready status
set(handles.status,'String','Ready');
但是当我尝试它时程序就像在计算过程之后执行命令一样,我错过了什么吗?
提前致谢...
答案 0 :(得分:1)
在开始计算之前尝试放置drawnow
。这将强制MATLAB刷新GUI事件队列。您还希望在回调函数的末尾添加另一个调用。