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
#4
You need to modify the logic. Right now you only save max (or make a copy) if interval coincides with K[ijk] > P[ijk]. You should split the two up.
            if (K[i][j][k]>P[0][j][k]:
                P[0][j][k]=K[i][j][k]
            if i % interval == 0:
                at_intervals.append(copy(P))
This will give you a copy at 0, 10, 20. If you want 9, 19, 29 the test is if (i+1) % interval == 0
Reply


Messages In This Thread
RE: Updating a matrix in a time interval inside a for loop - by deanhystad - May-17-2020, 07:02 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,775 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