Python Forum
when this error rise?index 28 is out of bounds for axis 0 with size 13
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
when this error rise?index 28 is out of bounds for axis 0 with size 13
#1
hi
this programm is the heat transfer module but in indexing i have problem this programm working on this way that i should know wher is this element that i select then i should make a Decision to how to fill it at last this array be a the system of equations and solve it.
import numpy as np
h=500+29/2
hg=np.zeros([13,29])
def on_line(i,j):
    if (i==0 and j in range(1,12)) :
        return 'bil'
    elif (i==28 and j in range(1,12)):
        return 'bir'
    elif (j==12 and i in range(1,29)):
        return 'bid'
    elif (i==0 and j==12):
        return 'cil'
    elif (i==28 and j==12):
        return 'cir'
    elif (i==0 and j==0):
        return 'ccvl'
    elif (i==28 and j==0):
        return 'ccvr'
    elif (i in range(1,9) and j==0) or (i in range(20,28) and j==0):
        return 'bcv'
    elif (i in range(10,19)and j==0):
        return 'bcvge'
    elif (i==9 and j==0)or(i==19 and j==0):
        return 'ccvgecd'
    elif (i==9 and j==4 ):
        return 'ccdgel'
    elif (i==28 and j==0):
        return 'ccdgel'
    elif (i==9 and j in range(1,5)):
        return 'cbl'
    elif (j==4 and i in range(10,19)):
        return 'cbd'
    elif (i==19 and j in range(1,5)):
        return 'cbr'
    elif (i in range(10,19)and j in range(1,4)):
        return 'c'
    else:
        return 'bo'
for i in range(29):
    for j in range(13):
        x=on_line(i,j)
        if x=='bil':
            hg[i][j]=(hg[i,j+1]+hg[i,j-1]+2*hg[i+1,j])/4
        if x=='cil':
            hg[i][j]=hg[i][j-1]+hg[i+1][j]
        if x=='bir':
            hg[i][j]=(hg[i][j+1]+hg[i][j-1]+2*hg[i-1][j])/4
Gribouillis write Nov-10-2020, 07:22 AM:
lease post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

I fixed for you this time. Please use code tags on future posts.
Reply
#2
Here's a simpler example:
import numpy as np
hg=np.zeros([13,29])
for i in range(29):
    for j in range(13):
        hg[i][j] = 1*13+j
Output:
Traceback (most recent call last): File "...", line 5, in <module> hg[i][j] = 1*13+j IndexError: index 13 is out of bounds for axis 0 with size 13
See the problem now? Look at the values for i and the shape of hg.

There may be other problems.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  IndexError: index 10 is out of bounds for axis 0 with size 10 Mehboob 11 1,956 Sep-14-2023, 06:54 AM
Last Post: Mehboob
  pyscript index error while calling input from html form pyscript_dude 2 938 May-21-2023, 08:17 AM
Last Post: snippsat
  Index error help MRsquared 1 739 May-15-2023, 03:28 PM
Last Post: buran
  I'm getting a String index out of range error debian77 7 2,280 Jun-26-2022, 09:50 AM
Last Post: deanhystad
  For loop index out of bounds armitron121 2 2,617 Feb-08-2022, 04:23 PM
Last Post: armitron121
  Sample labels from excel file in order to put them on x-axis and y-axis of a plot hobbyist 11 4,236 Sep-14-2021, 08:29 AM
Last Post: hobbyist
  Python Error List Index Out of Range abhi1vaishnav 3 2,239 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav
  Index error - columns vs non-column Vinny 3 4,849 Aug-09-2021, 04:46 PM
Last Post: snippsat
  How to resolve Index Error in my code? codify110 6 2,957 May-22-2021, 11:04 AM
Last Post: supuflounder
  IndexError: index 10 is out of bounds for axis 0 with size 1 vahid89 1 12,144 Jan-07-2021, 06:19 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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