By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,403 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,403 IT Pros & Developers. It's quick & easy.

Updating a matrix in a time interval inside a for loop

P: 1
I would like to get a maximum of a matrix in intervals inside for loop.

Matrix K has dimension (N,3,3). I like to have a matrix P (Max of K) between N 1 to 10, and then update it again with K and find the maximum at N 10 to 20.

So far I can get the maximum of the matrix K but can't update it in each interval.

Thanks in advance.



L=3
N=30
Interval=10
VB=[]
for nstep in np.arange(N):
V=[]
for i in range(0,L):
U=[]
for j in range(0,L):
m=i+4*(i)*j*nstep-5*j*i
U.append(m)
V.append(U)
VB.append(V)
K=np.array(VB)
P=np.zeros((1,L,L))
for i in range(0,N):
for j in range(0,L):
for k in range(0,L):
if (K[i][j][k]>P[0][j][k]and(i%interval!=0)):
P[0][j][k]=K[i][j][k]
2 Weeks Ago #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.