jeudi 3 décembre 2020

How to get a vector/array output from a loop within a function?

def solve_V(r,H,h):
    for i in h.tolist():
        if i<=r:
            const1=math.pi*(1/3)
            sqr=i**2
            radh=3*r-i
            V=const1*sqr*radh
        elif H+r>i>r:
            const2=2*(math.pi/3)
            radc=r**3
            radsq=r**2
            V=const2*radc+math.pi*radsq*(i-r)
    return [V]
print(solve_V(2.5,12,np.linspace(0,H,9)))

this is meant to give me all the values of V for the h array, however only one value is in the output which is for the largest value of h in the array

Aucun commentaire:

Enregistrer un commentaire