仅知道行数时如何访问数组中的元素?

I'm solving a system of differential equations in pythons to find Z.

sol = solve_ivp(conv, tspan, Z0,method='BDF')
aa=sol.t
bb=sol.y

then I'm finding X as

X=v1.dot(bb) where `v1`is a transformation matrix.

I need to find the value of second row of Xat every integration step to execute the program as

X[:,0]=[0,0,0,0]
def conv(t,Z):
   if  (second element of 4*1 X )> .7
   Zdot=A*Z+B*U
sol = solve_ivp(conv, tspan, Z0,method='BDF')
aa=sol.t
bb=sol.y
X=v1.dot(bb)

I want the if condition to be checked at every step and then the Zdot=A*Z+B*Uto be executed. I just know the no. of rows of X at every integration step so can't use a for loop. how do i do it?

评论