【问题标题】:if loops and Arraysif 循环和数组
【发布时间】:2016-11-14 22:40:00
【问题描述】:

我试图从实验中绘制一些数据,但计时器在我的变量开始之前启动了一点。我试图从 0 开始创建一个新的时间列表,但是当我这样做时,我的循环为我的数组生成更多的值,然后是原始数组的长度,这使得无法绘制。

Aplate = np.loadtxt('Plates Angular poston_2.txt')

t1 = []
for i in Aplate:
    t = Aplate[:,0]
      for j in t:
      if j < 27.4150:
         x = j -3.01 
         t1.append(x)
     else:
         break 

y = Aplate[:,1]

plt.plot(t1, y)
plt.show()

【问题讨论】:

  • 你有什么问题?
  • 您能否编辑您的问题并添加当前输出的示例以及您正在尝试实现的输出示例。

标签: arrays loops numpy if-statement


【解决方案1】:

如果您只是考虑数据记录开始时的持续延迟,为什么不这样做

plt.plot( t-delay ,y ) 

延迟是 3.01? (见这里:https://stackoverflow.com/a/4918586/4916534

另外,如果您希望列的长度相同,为什么不在同一个循环中填充 y 和 t 呢?您目前要求 python 为您提供所有时间

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 2020-10-28
    • 2016-02-13
    • 2021-03-23
    相关资源
    最近更新 更多