我希望我的列表附加8个数组

时间:2016-01-30 01:01:55

标签: arrays list append python-3.5

所以我将解释代码设计背后的目的。我希望列出一个长度为8的列表,每个iterable包含一个长度为80000的数组。代码意图是运行n = 0,然后跳转到for循环迭代超过80000,然后将数组附加到我之前定义的列表中。该过程将继续进行n - >所以列表有望为8宽和80000深。我正在刷掉我的蟒蛇灰,所以我似乎无法看到我的错误,我确定它很简单,谢谢你提前!

import numpy as np
import matplotlib.pyplot as plt
from math import exp
import random as rand

# grabs function ignoring constants and inputs into 2 column array
# with all t_values as well as the v(t) output

# lets add in constants
# let's write time constants in terms of us (microseconds)
theta = .1
T_clk = .004
theta = (theta / T_clk)
range_of_time = 80000


def v(tau):
    all_pulses = []
    start_times = list(range(20, 100, 10))
    pulses = np.zeros(range_of_time)

    for n in range(8):

        for ab in range(range_of_time):
            t = ab * T_clk
            pulses[ab] = (exp(-(t-start_times[n]))/tau - exp(-(t - start_times[n]))/theta)
        all_pulses.append(pulses)
    return all_pulses

print(v(55.7)[7])

0 个答案:

没有答案