Aim: Continuously read & plot data acquired from Arduino Uno + pressure transducer setup using "animatedline". After the experiment is done, hit "STOP" button on GUI, and gather data collected using "getpoints" to then be processed as necessary.
Problem: When I run the code, I am able to plot live signal from my transducer using "animatedline" (illustrated below).
The code that enables this is the following:
an = animatedline('Marker','.','Color','r','LineWidth',1.5);
ax = gca; box on
ax.XGrid = 'on'; ax.YGrid = 'on';
ax.YLim = [0 32];
ButtonHandle = uicontrol('Style', 'PushButton', ...
'String', 'STOP', ...
startTime = datetime('now');
eject = 0;
while t < 10
voltage = readVoltage(a,'A0');
maxP = 30; minP = 0;
pOffset = 7.44;
pressure = voltage*((maxP-minP)/(5-1))-pOffset;
t = datetime('now') - startTime;
ax.XLim = datenum([t-seconds(15) t]);
The code for the "STOP" button in the bottom left corner is below. I have this saved as a separate script, but in the same folder:
function exit_loop(hObject, eventdata, handles)
selection = questdlg('Sure you want to exit?',...
'Close Request Function',...
Once I hit "Yes," however, I then get this error:
Error using matlab.graphics.animation.AnimatedLine/addpoints
Value must be a handle.
Error in pRecord_v0 (line 117)
points to plot
Same error when I try to store the data from the experiment using the following:
[timeLog,pLog] = getpoints(an);
Any help you can offer is much appreciated!