仮想 COMM ポートを使用してリアルタイムでデータを読み込む Matlab スクリプトを作成しました。mfile でかなりの量の信号処理を行いました。
次に、情報をまとめて表示するコンパクトな GUI の必要性を感じました。
最近、Matlab の組み込み GUI ツールである GUIDE を掘り下げて読み始めました。いくつかのチュートリアルに従って、ボタンを押した後にグラフを GUI に表示することに成功しました。
ただし、GUI をリアルタイムで更新する必要があります。私のデータ ベクトルは常に更新されています (COMM ポートからデータを読み込みます)。更新のためにボタンを押すことに頼るのではなく、GUI が新しいデータでグラフを更新し続けることを望みます。誰かがバックグラウンド更新の正しい方向に私を向けることができますか?
現在 GUI に関連するコードは次のとおりです。
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global data
global time
% Time domain plot
axes(handles.timeDomainPlot);
cla;
plot (time, data);
EDIT 変更されたコード:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%Setting it to display something when it ends
% t = timer('TimerFcn', 'timerOn=false; disp(''Updating GUI!'')',...
t = timer(...
'TasksToExecute', 10, ... % Number of times to run the timer object
'Period', 3, ...
'TimerFcn', GUIUpdate());
%Starting the timer
start(t)
function GUIUpdate()
global data
global time
%Parameters below axes
global min
global max
% Time domain plot
axes(handles.timeDomainPlot);
cla;
plot (time, data);
%Other parameters:
set(handles.mean, 'String', mean);
set(handles.max, 'String', max);
私が得るエラーは次のとおりです。
??? Error using ==> GUI_Learning>GUIUpdate
Too many output arguments.
Error in ==>
@(hObject,eventdata)GUI_Learning('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback