【发布时间】:2021-06-01 09:50:22
【问题描述】:
我有一个传感器正在读取数据,我希望对其进行标准化。
f1020=[]
While True:
cmnd = getMsrMnt(filter.1020) #command to get a sensor value
f1020.append(cmnd.measurement) #write the sensor value to the above array
norm_f1020 = [(float(i)-min(f1020))/(max(f1020)-min(f1020)) for i in f1020] #normalize the data
但是,此时,我收到以下错误
ZeroDivisionError:浮点除以零
这将始终发生在索引 0 处,因为此时数组中只有一个值!如果有的话,我如何使用现有的norm_f1020 技术来解决这个错误。
【问题讨论】:
标签: arrays python-3.x normalization