He escrito un script de Matlab que lee datos usando un puerto COMM virtual en en tiempo real. He realizado una cantidad significativa de procesamiento de señal en un mfile.GUI de Matlab utilizando la GUÍA: Desea actualizar gráficamente los gráficos
A continuación, sentí la necesidad de tener una GUI compacta que muestre la información como un resumen.
Recientemente empecé a cavar y leer más de la herramienta GUI incorporada de Matlab, GUIDE. He seguido algunos tutoriales y puedo mostrar mis gráficos en mi GUI después de presionar un botón.
Sin embargo, quiero que la GUI se actualice en tiempo real. Mi vector de datos se actualiza constantemente (leyendo datos del puerto COMM). Quiero que la GUI mantenga actualizando los gráficos con los datos más nuevos, en lugar de confiar en un botón para actualizar. ¿Puede alguien señalarme en la dirección correcta para actualizar el fondo?
Este es el código relevante actualmente para la interfaz gráfica de usuario:
% --- 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);
editar el código modificado: Se
% --- 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);
El error que consigo es:
??? 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
Posible duplicado: http://stackoverflow.com/questions/1007385/getting-matlab-timer-to-update-matlab-guide-gui – Nzbuu
@ c0d3rz Echa un vistazo a este enlace sobre la definición de las devoluciones de llamada timerfcn http: // www. mathworks.com/help/techdoc/matlab_prog/f9-39541.html#f9-42494 Intenta configurar 'timerfcn' en @GUIUpdate y cambiando GUIUpdate para que tenga dos entradas 'GUIUpdate (obj, event)'. 'obj' será el manejador del objeto del temporizador y 'event' tendrá algunos detalles sobre cómo se llamó. Por defecto, las devoluciones de llamada a la función del temporizador se transmitirán al menos a esos dos argumentos. No estoy seguro de si esa es la causa exacta de su error, pero su muestra no parece correcta. Si tengo la oportunidad más tarde intentaré publicar un temporizador de ejemplo. –