0

I have written a code

u_pre = []
u_1 = np.zeros(tpts)
u_2 = np.zeros(tpts)
u_3 = np.zeros(tpts)

for i in range (0,tpts):
    a = u0[i]
    u_pre.append(a)

time = 0.00
timemax = 2001 #milli_s
while (time<timemax):
    uj_prime_stage1 = [matrix_C] @ (np.transpose(u0))

    for i in range(0,tpts):
        u_1[i] = u_pre[i] + 0.5 * (dt/a_sec) * (-c*(uj_prime_stage1[i]))

I am getting an error in the last line of this block of code as Exception has occurred: ValueError setting an array element with a sequence. I tried referring to other answers but could not find much help. u0 is a 1D array having tptselements. Any help is highly appreciated

Avii
  • 164
  • 11
  • Without a minimal reproducible example it's difficult to figure out what's wrong but if I had to guess I would think you might be mixing different types of objects, like suggested [here](https://stackoverflow.com/a/4675383/11072533). Maybe try setting `dtype=object` in the array initialisation and see if the error continues to occur. – CmdCoder858 Dec 26 '21 at 14:45

0 Answers0