Python Forum
Updating a matrix in a time interval inside a for loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating a matrix in a time interval inside a for loop
#2
Use python tags when posting code. I think I know what your program does, but without any indentation I cannot be sure.

If you want to keep P for each interval, why not do it this way:
L=3
N=30
Interval=10  # < Typo?  should be interval?
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)

at_intervals = []
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]
                at_intervals.append(copy(P))
Reply


Messages In This Thread
RE: Updating a matrix in a time interval inside a for loop - by deanhystad - May-17-2020, 05:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable definitions inside loop / could be better? gugarciap 2 484 Jan-09-2024, 11:11 PM
Last Post: deanhystad
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,919 Nov-07-2023, 09:49 AM
Last Post: buran
  Check if two matrix are equal and of not add the matrix to the list quest 3 886 Jul-10-2023, 02:41 AM
Last Post: deanhystad
  Mapping a value to an interval JazonKuer 12 2,108 Mar-17-2023, 07:59 PM
Last Post: Gribouillis
  Help adding a loop inside a loop Extra 31 4,752 Oct-23-2022, 12:16 AM
Last Post: Extra
  Confidence interval after doing penalised cox regression HatemAli 0 1,162 Feb-23-2022, 11:02 PM
Last Post: HatemAli
  How to immediately kill and restart a thread while using a time.sleep() inside it? philipbergwerf 4 3,595 Feb-07-2022, 04:16 PM
Last Post: Gribouillis
  How to multiply a matrix with herself, until the zero matrix results peanutbutterandjelly 3 3,410 May-03-2021, 06:30 AM
Last Post: Gribouillis
  How to measure execution time of a multithread loop spacedog 2 2,925 Apr-24-2021, 07:52 AM
Last Post: spacedog
  Adding to the dictionary inside the for-loop - weird behaviour InputOutput007 5 2,776 Jan-21-2021, 02:21 PM
Last Post: InputOutput007

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020