ので仮想COMMポートを使用してデータを読み込むMatlabスクリプトを作成しました。私はmfileで大量の信号処理を行っています。GUIDEを使用したMatlab GUI:グラフを動的に更新する
次に、情報を要約として表示するコンパクトな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
可能な複製:http://stackoverflow.com/questions/1007385/getting-matlab-timer-to-update-matlab-guide-gui – Nzbuu
@ c0d3rz timerfcnコールバックの定義については、このリンクを参照してください。http:// www。 mathworks.com/help/techdoc/matlab_prog/f9-39541.html#f9-42494 'timerfcn'を@GUIUpdateに設定し、GUIUpdateを2つの入力 'GUIUpdate(obj、event)'に変更してみてください。 'obj'はタイマーオブジェクトのハンドルになり、 'event'はそれがどのように呼び出されたかについていくつかの詳細を持ちます。デフォルトでは、タイマー関数のコールバックには、少なくとも2つの引数が渡されます。私はそれがあなたのエラーの正確な原因であるかどうかは分かりませんが、あなたのサンプルは正しく見えません。私が今日後でチャンスを得るなら、私はサンプルタイマーを投稿しようとします。 –