I was trying to design a program to receive a data and plot the real time information. This is my first time recording real time information. I needed two plots one with raw data and another with filtered data. But I can't even get the two graph to show the same information. Please help!!!
Error Message: Invalid or deleted object.
Error in trial2 (line 28)
ax.XLim = datenum([t-seconds(15) t]);
My code:
%% Clear all previous information from arduino board:
clc;clear;close all;%% Use the arduino command to connect to an Arduino device.
a = arduino;writeDigitalPin(a, 'D10', 1);%% Receiving signal from Arduino and plotting the live data:
figureh1 = animatedline;ax = gca;ax.YGrid = 'on';ax.YLim = [-5 5];stop = false;startTime = datetime('now');while ~stop v = readVoltage(a,'A0'); v2 = readVoltage(a,'A0')-1; t = datetime('now') - startTime; addpoints(h1,datenum(t),v) ax.XLim = datenum([t-seconds(15) t]); subplot(2,1,1) xlabel('Elapsed time (sec)') title('Raw Signal') drawnow subplot(2,1,2) xlabel('Elapsed time (sec)') title('Filtered Signal') drawnow datetick('x','keeplimits') stop = readDigitalPin(a,'D3');end
Best Answer