Speed-up the process of plotting real-time data (GUI)
Show older comments
Hi.
I have an Arduino board sending analog values (accelerometer data) via Bluetooth to MATLAB and I need to plot the data in real-time in a GUI axes. The problem is that there's a huge delay when plotting the data (although doing it outside the GUI doesn't raise this problems)...
I know I should preallocate to avoid copying the data from one array to another inside the loop but I'm not sure how to do that in this situation.
The goal is to plot 3 different variables in 3 different axes (one for each variable). The code inside the M-file OpeningFcn function for the Figure file is shown below:
t = 1 ;
x = 0 ;
y = 0;
z=0;
interv = 10000 ; % considering 1000 samples
fwrite(dev,uint8(20));
values = zeros(interv,2);
for t=1:1:interv
ax=fscanf(dev,'%d',1);
ay=fscanf(dev,'%d',1);
az=fscanf(dev,'%d',1);
%values(t,:)=[a,b];
x = [ x, ax ];
axes(handles.axes1);
plot(x, 'r') ;
ylim([-200 200]);
drawnow;
end
fclose(dev);
Any help would be much appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!