%function realtime()
%realtime display/record
%TRY
s2 = serial('COM2', 'BaudRate', 9600,'databits',7, 'timeout',10, 'stopbit', 1);
%s2 = serial('COM3', 'BaudRate', 9600,'databits',7, 'timeout',10, 'stopbit', 1);

fopen(s2)
X = 0;  
while X < 60;              % number of times graph repeats
X = X+1;

ind = fread(s2,500);        % fread(s2,# of points)
data  = (ind -1 ) * 5 ;     % -1 for 0's correction, 5x for resolution of RPM
%x = x + 1;
%end;
time = (1:1:500)';          % (1:1:# of points)'
time = time / 500;
plot (time,data, '-');
xlabel('Time [ms]');
ylabel('RPM');
title('Actual Data');
axis([0,200/200,0,500]);    % X/200 for 5ms for time between data received
pause (.1)

end
fclose(s2)
%end