Update plot in GUIDE
Afficher commentaires plus anciens
I have a timer function that ticks every second and calls a display update function:
function update_display(hObject,eventdata,hfigure)
% Timer timer1 callback, called each time timer iterates.
% Update plot data
handles = guidata(hfigure);
set(handles.main_plot, 'XData', [1:length(handles.data)],'YData',handles.data)
drawnow
guidata(hfigure, handles);
% END USER CODE
Problem is, the plot doesnt update.I know the function is entered. Also in the program there is a bytesavailablefcn that triggers and harvests data from the serial port:
% START USER CODE
function update_function(hObject,eventdata,hfigure)
handles = guidata(hfigure)
fread(handles.s, 1,'int8');
fread(handles.s, 1,'int8');
fread(handles.s, 1,'int8');
handles.data(handles.count) = (fread(handles.s, 1,'uint8'));
fread(handles.s, 1,'int8');
fread(handles.s, 1,'int8');
fread(handles.s, 1,'int8');
fread(handles.s, 1,'int8');
fread(handles.s, 1,'int8');
handles.count = handles.count + 1;
handles.s.BytesAvailable;
handles.s.ValuesReceived;
guidata(hfigure, handles)
There's about 540 bytes arriving per second, and the function harvests every 9 bytes (so 60 times a second) but this doesnt seem to be the issue.
I know that the timer callback is being executed every second, it should be uninterruptible by default I read. Could it be because there are too many values in the array to plot? I am suspicious that the timer callback function is actually being interrupted.
Can anyone see where I'm going wrong?
Cheers
1 commentaire
Martin Thompson
le 27 Fév 2018
Réponses (0)
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!