Index out of range appears sometimes and disappears when i run again python -
import numpy import matplotlib.pyplot plt import serial v=[] i=[] p=[] count=0 arduinodata=serial.serial('/dev/ttyacm0',9600) # importing serial data a=input('enter no of observation required = ') # user choice required no of observations while count<a: count=count+1 while(arduinodata.inwaiting()==0): pass arduinostring=arduinodata.readline() data=arduinostring.split(",") voltage = float(data[0]) current = float(data[1]) power = float(data[2]) v.append(voltage) i.append(current) p.append(power) print v,",",i,",",p #plt.plot(v)`enter code here` #plt.show() #plt.ylim([150])
i error off , on code works fine , index out of range i'm confused why have started learning python programming
have checked string make sure has 3 comma separated elements? if doesn't may need treat malformed , throw away.
Comments
Post a Comment