Hello I have made the following code to plot the recieved data from serial comm
However at some point (different each time) it throws the index exceeds array size.
How its possible
However at some point (different each time) it throws the index exceeds array size.
How its possible
Code:
clear all
sObject=serial('COM4','BaudRate',115200,'TimeOut',10,'Terminator','LF');
fopen(sObject);
i=1;
while(1)
data=fscanf(sObject);
plot(total);
pause(0.05);
total(i)=double(uint8(data(1)))+double(uint8(data(2)))+double(uint8(data(3)));
i=i+1;
flushinput(sObject);
end
fclose(sObject);